Skip to content

Commit

Permalink
Adding test for reverse direction
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulOstazeski committed Jan 23, 2025
1 parent 6f917aa commit 3b20b86
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/ecto/migration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,23 @@ defmodule Ecto.MigrationTest do
assert {:create, %Index{}} = last_command()
end

test "renames an index" do
rename index(:people, [:name]), to: "person_names_idx"
flush()
{_, index, old_name} = last_command()
assert old_name == :people_name_index
assert is_nil(index.prefix)
end

@tag prefix: "foo"
test "renames an index with a prefix" do
rename index(:people, [:name]), to: "person_names_idx"
flush()
{_, index, old_name} = last_command()
assert old_name == :people_name_index
assert index.prefix == "foo"
end

test "drops a constraint" do
assert_raise Ecto.MigrationError, ~r/cannot reverse migration command/, fn ->
drop_if_exists constraint(:posts, :price)
Expand Down

0 comments on commit 3b20b86

Please sign in to comment.