Class: ActiveRecord::SchemaDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/foreign_key_saver/foreign_key_saver_patches.rb

Instance Method Summary collapse

Instance Method Details

#foreign_key_constraints_on(table_name, stream) ⇒ Object



189
190
191
192
193
# File 'lib/foreign_key_saver/foreign_key_saver_patches.rb', line 189

def foreign_key_constraints_on(table_name, stream)
  constraints = @connection.foreign_key_constraints_on(table_name)
  constraints.each {|constraint| stream.puts "  add_foreign_key_constraint #{table_name.inspect}, #{constraint.to_dump}"}
  stream.puts unless constraints.empty?
end

#tables_with_foreign_key_constraints(stream) ⇒ Object



195
196
197
198
# File 'lib/foreign_key_saver/foreign_key_saver_patches.rb', line 195

def tables_with_foreign_key_constraints(stream)
  tables_without_foreign_key_constraints(stream)
  @connection.tables.sort.each {|table| foreign_key_constraints_on(table, stream)}
end