Add a foreign key to existing tables in Rails (MySQL)

Posted by randombits on Stack Overflow See other posts from Stack Overflow or by randombits
Published on 2010-04-15T01:50:46Z Indexed on 2010/04/15 1:53 UTC
Read the original article Hit count: 213

Filed under:
|

What's the best way to add foreign keys to my existing tables in Rails with an underlying MySQL database? clearly the solution should be done in a migration, as I want this versioned. Otherwise I'd create the constraints myself.

I can't seem to find one, conducive response to they above. Again, the tables have already been created with previous migrations. I'm just going back now and adding referential integrity wherever it's applicable.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about migration