In Ruby on Rails, how to add foreign key constraint in migration?
Here's a gem-based solution that includes support for adding and removing foreign key constraints, doesn't fail with sqlite, and works correctly with schema.rb files:
http://github.com/matthuhiggins/foreigner