diff options
author | Kir Shatrov <shatrov@me.com> | 2017-06-14 22:39:19 -0400 |
---|---|---|
committer | Kir Shatrov <shatrov@me.com> | 2017-06-16 20:49:09 -0400 |
commit | 675a912eb86a9e109e9877379e8454b388242d57 (patch) | |
tree | ecab51147d760a892965f570e790a2e6f482765d /activerecord/test | |
parent | f1e42fe267342ffa4cea84cf09b0caaee733632c (diff) | |
download | rails-675a912eb86a9e109e9877379e8454b388242d57.tar.gz rails-675a912eb86a9e109e9877379e8454b388242d57.tar.bz2 rails-675a912eb86a9e109e9877379e8454b388242d57.zip |
Remove FK together with column in MySQL
Unlike with other databses, MySQL doesn't let you remove the column
if there's a FK on this column.
For better developer experience we want to remove the FK together with
the column.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration/references_foreign_key_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/references_foreign_key_test.rb b/activerecord/test/cases/migration/references_foreign_key_test.rb index f1ddac1ee2..718b9a0613 100644 --- a/activerecord/test/cases/migration/references_foreign_key_test.rb +++ b/activerecord/test/cases/migration/references_foreign_key_test.rb @@ -139,6 +139,16 @@ if ActiveRecord::Base.connection.supports_foreign_keys? end end + test "removing column removes foreign key" do + @connection.create_table :testings do |t| + t.references :testing_parent, index: true, foreign_key: true + end + + assert_difference "@connection.foreign_keys('testings').size", -1 do + @connection.remove_column :testings, :testing_parent_id + end + end + test "foreign key methods respect pluralize_table_names" do begin original_pluralize_table_names = ActiveRecord::Base.pluralize_table_names |