From 33ce73edf1d1b02f4f50fc5d7565590468167d76 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Mon, 6 Aug 2018 11:38:44 +0000 Subject: SQLite3 adapter `alter_table` method restores foreign keys Related to #33520 --- activerecord/test/cases/migration/foreign_key_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb index c471dd1106..4b43f57732 100644 --- a/activerecord/test/cases/migration/foreign_key_test.rb +++ b/activerecord/test/cases/migration/foreign_key_test.rb @@ -64,6 +64,19 @@ if ActiveRecord::Base.connection.supports_foreign_keys_in_create? assert_equal "astronauts", fk.from_table assert_equal "rockets", fk.to_table end + + def test_rename_column_of_child_table + rocket = Rocket.create!(name: "myrocket") + rocket.astronauts << Astronaut.create! + + @connection.rename_column :astronauts, :name, :astronaut_name + + foreign_keys = ActiveRecord::Base.connection.foreign_keys("astronauts") + fk = foreign_keys.first + assert_equal "myrocket", Rocket.first.name + assert_equal "astronauts", fk.from_table + assert_equal "rockets", fk.to_table + end end end end -- cgit v1.2.3