In PHP Doctrine, is it possible to create one migration class that creates a table and creates a foreign key on that table?
For some reason, I can’t get the foreign key to work …
class Migration_001 extends Doctrine_Migration_Base {
public function up() {
$this->createTable('table_name', array(...))
$this->createForeignKey('table_name', 'foreign_key_name', array(...))
}
public function down() {
$this->dropForeignKey('table_name', 'foreign_key_name')
$this->dropTable('table_name')
}
}
Thanks,
Ofir
To answer my own question, the answer is yes.
You do have to check that everything is in order, though, meaning that the columns should be identical (type, length, etc.) and also that the foreign key is a unique key in his own table (I don’t remember but maybe it should also be the first column).