tom
tom

Reputation: 8359

How to drop a foreign key in doctrine 2 migrations

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

Does anybody know how to drop it?

Upvotes: 4

Views: 3756

Answers (2)

Matt Styles
Matt Styles

Reputation: 536

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

Upvotes: 4

mPrinC
mPrinC

Reputation: 9401

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

Upvotes: -2

Related Questions