Skip to content

Commit 557335f

Browse files
committed
Read migration source from config still
1 parent bf80ce9 commit 557335f

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

lib/ecto/migrator.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ defmodule Ecto.Migrator do
481481
Keyword.get(opts, :migration_lock, Keyword.get(config, :migration_lock, true))
482482

483483
opts =
484-
Keyword.put_new(opts, :migration_source, config[:migration_source] || "schema_migrations")
484+
Keyword.put(opts, :migration_source, config[:migration_source] || "schema_migrations")
485485

486486
result =
487487
if lock_or_migration_number && migration_lock? do

test/ecto/migrator_test.exs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ defmodule Ecto.MigratorTest do
187187
def change, do: flush()
188188
end
189189

190-
Application.put_env(:ecto_sql, MigrationSourceRepo, [migration_source: "my_schema_migrations"])
191190
@moduletag migrated_versions: [{1, nil}, {2, nil}, {3, nil}]
192191

193192
setup context do
@@ -394,12 +393,6 @@ defmodule Ecto.MigratorTest do
394393
refute_received {:lock_for_migrations, _, _, _}
395394
end
396395

397-
test "on migration_source" do
398-
assert up(TestRepo, 9, Migration, log: false, migration_source: "custom") == :ok
399-
assert_receive {:lock_for_migrations, _, _, opts}
400-
assert opts[:migration_source] == "custom"
401-
end
402-
403396
test "on migration_lock" do
404397
assert up(TestRepo, 9, Migration, log: false, migration_lock: false) == :ok
405398
refute_receive {:lock_for_migrations, _, _, _}
@@ -410,13 +403,16 @@ defmodule Ecto.MigratorTest do
410403
create_migration "13_sample.exs"
411404
assert run(TestRepo, path, :up, all: true, log: false) == [13]
412405
# One lock for fetching versions, another for running
413-
assert_receive {:lock_for_migrations, _, _, _}
414-
assert_receive {:lock_for_migrations, _, _, _}
406+
assert_receive {:lock_for_migrations, _, _, opts}
407+
assert opts[:migration_source] == "schema_migrations"
408+
assert_receive {:lock_for_migrations, _, _, opts}
409+
assert opts[:migration_source] == "schema_migrations"
415410

416411
create_migration "14_sample.exs", [:disable_migration_lock]
417412
assert run(TestRepo, path, :up, all: true, log: false) == [14]
418413
# One lock for fetching versions, another from running
419-
assert_receive {:lock_for_migrations, _, _, _}
414+
assert_receive {:lock_for_migrations, _, _, opts}
415+
assert opts[:migration_source] == "schema_migrations"
420416
refute_received {:lock_for_migrations, _, _, _}
421417
end
422418
end
@@ -452,8 +448,7 @@ defmodule Ecto.MigratorTest do
452448
expected_result = [{:up, 15, "sample"}]
453449
assert migrations(TestRepo, path) == expected_result
454450

455-
assert_receive {:lock_for_migrations, _, _, opts}
456-
assert opts[:migration_source] == "schema_migrations"
451+
assert_receive {:lock_for_migrations, _, _, _}
457452
refute_received {:lock_for_migrations, _, _, _}
458453

459454
assert match?({:create_if_not_exists, %_{name: :schema_migrations}, _}, last_command())

0 commit comments

Comments
 (0)