Module: ActiveRecord::ConnectionAdapters::SchemaStatements
- Defined in:
- lib/forceful_foreign_key.rb
Instance Method Summary collapse
Instance Method Details
#add_foreign_key(from_table, to_table, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/forceful_foreign_key.rb', line 7 def add_foreign_key(from_table, to_table, = {}) return unless supports_foreign_keys? if [:force] graph = ForcefulForeignKey::Graph.new graph.build_graph graph.delete_orphans(from_table: from_table, from_column: [:column] || "#{to_table}_id", target_table: to_table, target_column: [:primary_key] || 'id') end old_add_foreign_key from_table, to_table, end |
#old_add_foreign_key ⇒ Object
5 |
# File 'lib/forceful_foreign_key.rb', line 5 alias_method :old_add_foreign_key, :add_foreign_key |