Skip to content

Commit 40b579a

Browse files
committed
fix(test): test_remove_foreign_key_on_8_0
Since CockroachDB does not support DDL transactions, we adapt the test.
1 parent e21bdaf commit 40b579a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/excludes/ActiveRecord/Migration/CompatibilityTest.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,34 @@ def on_sym(node)
1717
insert_after(node.loc.expression, "_and_actually_way_longer_because_cockroach_is_in_the_128_game")
1818
end
1919
end
20+
21+
# CockroachDB does not support DDL transactions. Hence the migration is
22+
# not rolled back and the already removed index is not restored.
23+
#
24+
# From:
25+
# if current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter)
26+
# assert_equal 2, foreign_keys.size
27+
# else
28+
# assert_equal 1, foreign_keys.size
29+
# end
30+
# To:
31+
# assert_equal 1, foreign_keys.size
32+
CopyCat.copy_methods(self, self, :test_remove_foreign_key_on_8_0) do
33+
def on_if(node)
34+
return unless node in
35+
[:if,
36+
[:send, nil, :current_adapter?,
37+
[:sym, :PostgreSQLAdapter],
38+
[:sym, :SQLite3Adapter]],
39+
[:send, nil, :assert_equal,
40+
[:int, 2],
41+
[:send,
42+
[:lvar, :foreign_keys], :size]],
43+
[:send, nil, :assert_equal,
44+
[:int, 1],
45+
[:send,
46+
[:lvar, :foreign_keys], :size]] => else_block]
47+
48+
replace(node.loc.expression, else_block.location.expression.source)
49+
end
50+
end

0 commit comments

Comments
 (0)