How to drop a foreign key in doctrine 2 migrations

微笑、不失礼 提交于 2019-12-12 11:22:52

问题


I want to drop a foreign key in a doctrine 2 migration. But there is no dropForeignKeyConstraint()

Does anybody know how to drop it?


回答1:


public function down(Schema $schema)
{
    $table = $schema->getTable('table_name');
    $table->removeForeignKey('foreign_key_name');
}



回答2:


Here it is:

public function down()
{
    $this->dropForeignKey('table_name', 'email_foreign_key');
}

http://www.doctrine-project.org/projects/orm/1.2/docs/manual/migrations/en



来源:https://stackoverflow.com/questions/3643344/how-to-drop-a-foreign-key-in-doctrine-2-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!