diff --git a/test/add_index_test.rb b/test/add_index_test.rb index 5250a8f3..25c5e1b8 100644 --- a/test/add_index_test.rb +++ b/test/add_index_test.rb @@ -92,7 +92,7 @@ def test_corruption end end - def test_lock_timeout + def test_remove_invalid_indexes skip unless postgresql? with_locked_table("users") do @@ -109,6 +109,12 @@ def test_lock_timeout StrongMigrations.stub(:remove_invalid_indexes, true) do migrate AddIndexConcurrently + + # fail if trying to add the same index in a future migration + error = assert_raises(ActiveRecord::StatementInvalid) do + migrate AddIndexConcurrently + end + assert_kind_of PG::DuplicateTable, error.cause end migrate AddIndexConcurrently, direction: :down