class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Public Instance Methods

add_referential_integrity(table, keypairs) click to toggle source
# File lib/activerecord/referential_integrity/active_record/connection_adapters/postgresql_adapter.rb, line 2
def add_referential_integrity(table, keypairs)
  keypairs.each_pair do |foreign_key, foreign_table|
    execute "ALTER TABLE #{table} ADD CONSTRAINT #{table}_fk_#{foreign_key} FOREIGN KEY (#{foreign_key}) REFERENCES #{foreign_table} (id)"
  end
end
drop_referential_integrity(table, keys) click to toggle source
# File lib/activerecord/referential_integrity/active_record/connection_adapters/postgresql_adapter.rb, line 8
def drop_referential_integrity(table, keys)
  keys.each do |foreign_key|
    execute "ALTER TABLE #{table} DROP CONSTRAINT IF EXISTS #{table}_fk_#{foreign_key}"
  end
end