# db/migrate/6_add_foreign_key.rb
class AddForeignKey < ActiveRecord::Migration
def self.up
execute "ALTER TABLE bees ADD CONSTRAINT beehive_id_fkey FOREIGN KEY
(beehive_id) REFERENCES beehives (id);"
end
def self.down
execute "ALTER TABLE bees DROP CONSTRAINT beehive_id_fkey;"
end
end
class AddForeignKey < ActiveRecord::Migration
def self.up
execute "ALTER TABLE user_notes ADD CONSTRAINT creator_id_fkey FOREIGN KEY (creator_id) REFERENCES users (id);"
end
def self.down
execute "ALTER TABLE user_notes DROP CONSTRAINT creator_id_fkey;"
end
end