From 6951566f365c21f31435c5918e7f2858e55a13ec Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 3 May 2021 13:38:29 +0900 Subject: [PATCH] Fix `add_foreign_key` to prevent double prefix/suffix --- activerecord/lib/active_record/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 8b8f6d029f..8c328d8b99 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -921,7 +921,7 @@ module ActiveRecord unless connection.respond_to? :revert unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method) arguments[0] = proper_table_name(arguments.first, table_name_options) - if [:rename_table, :add_foreign_key].include?(method) || + if method == :rename_table || (method == :remove_foreign_key && !arguments.second.is_a?(Hash)) arguments[1] = proper_table_name(arguments.second, table_name_options) end