phalcon/phalcon-devtools — pull request #123 by MatejBalantic (2013-10-16 12:44:15+00:00)
Title: Updating model builder to build proper syntax for foreign key

As noted in those two issues:
https://github.com/phalcon/phalcon-devtools/issues/47
http://forum.phalconphp.com/discussion/436/generate-model-error-with-addforeignkey-method

model generator currently builds foreign key syntax like that:
$this->belongsTo("id", "Objects", "id");
$this->addForeignKey("id", "Objects", "id");

However, based on documentation of lates phalcon:
http://docs.phalconphp.com/en/latest/reference/models.html#virtual-foreign-keys

it should have been like that:
$this->belongsTo("owner_id", "Objects", "id", array(
'foreignKey' => true
));

I updated the builder to support the new syntax. The update is done in a way that supports additional options in future.