So here’s a little rake task to bring them back, assuming that your environment is exactly like mine.
namespace :db do
task :restore_foreign_keys => :environment do
schema = File.open("db/schema.rb").readlines
foreign_key_statements = schema.grep /add_foreign_key/
foreign_key_statements.each do |statement|
That code is really very ruby. Open the file, read the relevant lines, then.. just eval them in the context of the connection object and hope for the best.