@@ -821,6 +821,23 @@ defmodule Ecto.MigrationTest do
821821 assert index . prefix == "baz"
822822 end
823823
824+ test "renames an index" do
825+ rename index ( :people , [ :name ] ) , to: "person_names_idx"
826+ flush ( )
827+ { _ , index , new_name } = last_command ( )
828+ assert new_name == "person_names_idx"
829+ assert is_nil ( index . prefix )
830+ end
831+
832+ @ tag prefix: "foo"
833+ test "renames an index with a prefix" do
834+ rename index ( :people , [ :name ] ) , to: "person_names_idx"
835+ flush ( )
836+ { _ , index , new_name } = last_command ( )
837+ assert new_name == "person_names_idx"
838+ assert index . prefix == "foo"
839+ end
840+
824841 test "executes a command" do
825842 execute "SELECT 1" , "SELECT 2"
826843 flush ( )
@@ -1004,6 +1021,23 @@ defmodule Ecto.MigrationTest do
10041021 assert { :create , % Index { } } = last_command ( )
10051022 end
10061023
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+
10071041 test "drops a constraint" do
10081042 assert_raise Ecto.MigrationError , ~r/ cannot reverse migration command/ , fn ->
10091043 drop_if_exists constraint ( :posts , :price )
0 commit comments