Skip to content

Commit 3b20b86

Browse files
committed
Adding test for reverse direction
1 parent 6f917aa commit 3b20b86

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/ecto/migration_test.exs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,23 @@ defmodule Ecto.MigrationTest do
10211021
assert {:create, %Index{}} = last_command()
10221022
end
10231023

1024+
test "renames an index" do
1025+
rename index(:people, [:name]), to: "person_names_idx"
1026+
flush()
1027+
{_, index, old_name} = last_command()
1028+
assert old_name == :people_name_index
1029+
assert is_nil(index.prefix)
1030+
end
1031+
1032+
@tag prefix: "foo"
1033+
test "renames an index with a prefix" do
1034+
rename index(:people, [:name]), to: "person_names_idx"
1035+
flush()
1036+
{_, index, old_name} = last_command()
1037+
assert old_name == :people_name_index
1038+
assert index.prefix == "foo"
1039+
end
1040+
10241041
test "drops a constraint" do
10251042
assert_raise Ecto.MigrationError, ~r/cannot reverse migration command/, fn ->
10261043
drop_if_exists constraint(:posts, :price)

0 commit comments

Comments
 (0)