diff options
author | Matthew Draper <matthew@trebex.net> | 2016-01-07 01:11:17 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-01-07 01:11:17 +1030 |
commit | 998b85ffe8997bb4da23f8ff65d3f4bb59e90a7e (patch) | |
tree | cd75139cb9baf12e2be902f3c0896017349354e9 /activerecord/test | |
parent | 4137d44b2282abb7a7e7763f0abdc2fc108065ba (diff) | |
parent | 76dc41abdb33f69c078818dd8142bdf47834baa5 (diff) | |
download | rails-998b85ffe8997bb4da23f8ff65d3f4bb59e90a7e.tar.gz rails-998b85ffe8997bb4da23f8ff65d3f4bb59e90a7e.tar.bz2 rails-998b85ffe8997bb4da23f8ff65d3f4bb59e90a7e.zip |
Merge pull request #22941 from lsylvester/pg-remove-index-legacy
Fix remove_index for postgresql when running legacy migrations
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration/compatibility_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb index 267d2fcccc..b1e1d72944 100644 --- a/activerecord/test/cases/migration/compatibility_test.rb +++ b/activerecord/test/cases/migration/compatibility_test.rb @@ -21,6 +21,7 @@ module ActiveRecord teardown do connection.drop_table :testings rescue nil ActiveRecord::Migration.verbose = @verbose_was + ActiveRecord::SchemaMigration.delete_all end def test_migration_doesnt_remove_named_index @@ -37,6 +38,21 @@ module ActiveRecord assert_raise(StandardError) { ActiveRecord::Migrator.new(:up, [migration]).migrate } assert connection.index_exists?(:testings, :foo, name: "custom_index_name") end + + def test_migration_does_remove_unnamed_index + connection.add_index :testings, :bar + + migration = Class.new(ActiveRecord::Migration[4.2]) { + def version; 101 end + def migrate(x) + remove_index :testings, :bar + end + }.new + + assert connection.index_exists?(:testings, :bar) + ActiveRecord::Migrator.new(:up, [migration]).migrate + assert_not connection.index_exists?(:testings, :bar) + end end end end |