Yitzchok / subsonicproject

Automatically exported from code.google.com/p/subsonicproject
0 stars 0 forks source link

Migration DropForeignKey fails for MySQL #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
With Subsonic Migrations the command

CreateForeignKey(parenttable.GetColumn("Id"),
childtable.GetColumn("parentId"));

creates a Foreign key as expected. But If I try to remove this foreign key
in the down method with

DropForeignKey(parenttable.GetColumn("Id"), childtable.GetColumn("parentId"));

the generated command:

ALTER TABLE `child` DROP CONSTRAINT fk_parent_id_parentid;

fails for mysql, because the "CONSTRAINT" keyword is not supported as
discussed here: http://bugs.mysql.com/bug.php?id=3742

You have to write:

ALTER TABLE `child` DROP FOREIGN KEY fk_parent_id_parentid;

I created a patch which overrides the BuildForeignKeyDropStatement for MySQL

Original issue reported on code.google.com by j.steinblock@gmail.com on 30 Apr 2009 at 3:36

Attachments: