On Jan 31, 4:55 am, Yorick Peterse <[email protected]> wrote:
> Folks,
>
> Yesterday I noticed one of my tables required an extra column along with a
> foreign key that refers to an external table. I created the migration's up
> block, tested it and it worked fine.
> However, when creating the down block I couldn't figure out how to drop a
> foreign key. Sequel doesn't have a method "drop_foreign_key" like it does
> for columns and constraints so that didn't work.
> After some googling I noticed that a person reported a similar issue before
> (Gcode ticket #284), in that ticket Jeremy replied saying that this could be
> achieved by storing the FK using a custom constraint name
> and then using "drop_constraint" to drop that particular foreign key. Now
> here's the problem, that doesn't work either. In MySQL foreign keys are
> dropped using "DROP FOREIGN KEY" rather than "DROP CONSTRAINT"
> (correct me if I'm wrong) and thus the latter produces a syntax error as
> seen here:http://scrp.at/tA. My migration looks like the 
> following:http://scrp.at/tB
>
> If anybody could point me out how to properly remove a foreign key that
> would be wonderful. If more details are required feel free to ask for them
> :]

How you remove a foreign key constraint varies between databases.  It
would certainly be nice if Sequel could abstract it, but currently
there is no support for that.

For MySQL, you'll currently have to do use DROP FOREIGN KEY with the
appropriate constraint name, see 
http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to