From 6b9948c85e174b77b4e4e4a904c2b6fcf1083628 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 6 Aug 2018 14:00:22 +0800 Subject: Allow `to_table` in `invert_remove_foreign_key` remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen] --- .../connection_adapters/abstract/schema_statements.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 3be0906f2a..fd9bf48ab5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -980,11 +980,18 @@ module ActiveRecord # # remove_foreign_key :accounts, column: :owner_id # + # Removes the foreign key on +accounts.owner_id+. in a reversible manner + # + # remove_foreign_key :accounts, column: :owner_id, to_table: :owners + # # Removes the foreign key named +special_fk_name+ on the +accounts+ table. # # remove_foreign_key :accounts, name: :special_fk_name # - # The +options+ hash accepts the same keys as SchemaStatements#add_foreign_key. + # The +options+ hash accepts the same keys as SchemaStatements#add_foreign_key + # with an addition of + # [:to_table] + # The table contains the referenced primary key. def remove_foreign_key(from_table, options_or_to_table = {}) return unless supports_foreign_keys? -- cgit v1.2.3