diff --git a/test/safe_by_default_test.rb b/test/safe_by_default_test.rb index fb12d13f..729e4002 100644 --- a/test/safe_by_default_test.rb +++ b/test/safe_by_default_test.rb @@ -135,7 +135,7 @@ def test_add_foreign_key_column end def test_add_foreign_key_invalid - skip unless postgresql? && ActiveRecord::VERSION::STRING.to_f >= 7.1 + skip unless postgresql? user = User.create!(order_id: 1) @@ -146,7 +146,13 @@ def test_add_foreign_key_invalid user.update!(order_id: nil) - migrate AddForeignKey + if ActiveRecord::VERSION::STRING.to_f >= 7.1 + migrate AddForeignKey + else + assert_raises(ActiveRecord::StatementInvalid) do + migrate AddForeignKey + end + end # fail if trying to add the same foreign key in a future migration assert_raises(ActiveRecord::StatementInvalid) do