Skip to content

Commit bb1bd84

Browse files
authored
Use custom migration module for auth migration. (#6605)
1 parent d4ec4b7 commit bb1bd84

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

priv/templates/phx.gen.auth/migration.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule <%= inspect schema.repo %>.Migrations.Create<%= Macro.camelize(schema.table) %>AuthTables do
2-
use Ecto.Migration
2+
use <%= inspect schema.migration_module %>
33

44
def change do<%= if Enum.any?(migration.extensions) do %><%= for extension <- migration.extensions do %>
55
<%= extension %><% end %>

test/mix/tasks/phx.gen.auth_test.exs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,29 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do
841841
end)
842842
end
843843

844+
test "generates migration with a custom migration module", config do
845+
in_tmp_phx_project(config.test, fn ->
846+
send(self(), {:mix_shell_input, :yes?, false})
847+
848+
try do
849+
Application.put_env(:ecto_sql, :migration_module, MyCustomApp.MigrationModule)
850+
851+
Gen.Auth.run(
852+
~w(Accounts User users --no-compile),
853+
ecto_adapter: Ecto.Adapters.Postgres
854+
)
855+
856+
assert [migration] = Path.wildcard("priv/repo/migrations/*_create_users_auth_tables.exs")
857+
858+
assert_file(migration, fn file ->
859+
assert file =~ "use MyCustomApp.MigrationModule"
860+
end)
861+
after
862+
Application.delete_env(:ecto_sql, :migration_module)
863+
end
864+
end)
865+
end
866+
844867
test "supports --binary-id option", config do
845868
in_tmp_phx_project(config.test, fn ->
846869
send(self(), {:mix_shell_input, :yes?, false})

0 commit comments

Comments
 (0)