Skip to content

Commit 6705443

Browse files
committed
Revert "Disable migration lock by default on CheckRepoStatus (#196)"
This reverts commit 95fde93.
1 parent 3cb5053 commit 6705443

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

lib/phoenix_ecto/check_repo_status.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Phoenix.Ecto.CheckRepoStatus do
99
1010
* `:otp_app` - name of the application which the repos are fetched from
1111
* `:migration_paths` - a function that accepts a repo and returns a migration directory, or a list of migration directories, that is used to check for pending migrations
12-
* `:migration_lock` - the locking strategy used by the Ecto Adapter when checking for pending migrations. Defaults to `false`. Set to `true` to enable migration locks.
12+
* `:migration_lock` - the locking strategy used by the Ecto Adapter when checking for pending migrations. Set to `false` to disable migration locks.
1313
* `:prefix` - the prefix used to check for pending migrations.
1414
* `:skip_table_creation` - Ecto will not try to create the `schema_migrations` table automatically. This is useful if you are connecting as a DB user without create permissions
1515
"""
@@ -67,11 +67,7 @@ defmodule Phoenix.Ecto.CheckRepoStatus do
6767
end)
6868

6969
true = is_function(migrations_fun, 3)
70-
71-
migration_opts =
72-
opts
73-
|> Keyword.take(@migration_opts)
74-
|> Keyword.put_new(:migration_lock, false)
70+
migration_opts = Keyword.take(opts, @migration_opts)
7571

7672
try do
7773
repo

test/phoenix_ecto/check_repo_status_test.exs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,17 @@ defmodule Phoenix.Ecto.CheckRepoStatusTest do
111111

112112
conn = conn(:get, "/")
113113

114-
# default is false
115-
exception =
116-
assert_wrapped(Phoenix.Ecto.PendingMigrationError, fn ->
117-
CheckRepoStatus.call(
118-
conn,
119-
otp_app: :check_repo_ready,
120-
mock_migrations_fn: mock_migrations_fn
121-
)
122-
end)
123-
124-
assert exception.migration_opts == [migration_lock: false]
125-
126-
# can be overridden to true
127114
exception =
128115
assert_wrapped(Phoenix.Ecto.PendingMigrationError, fn ->
129116
CheckRepoStatus.call(
130117
conn,
131118
otp_app: :check_repo_ready,
132119
mock_migrations_fn: mock_migrations_fn,
133-
migration_lock: true
120+
migration_lock: false
134121
)
135122
end)
136123

137-
assert exception.migration_opts == [migration_lock: true]
124+
assert exception.migration_opts == [migration_lock: false]
138125
after
139126
Application.delete_env(:check_repo_ready, :ecto_repos)
140127
Process.unregister(StorageUpRepo)
@@ -164,7 +151,7 @@ defmodule Phoenix.Ecto.CheckRepoStatusTest do
164151
)
165152
end)
166153

167-
assert Keyword.get(exception.migration_opts, :prefix) == "tenant_1"
154+
assert exception.migration_opts == [prefix: "tenant_1"]
168155
after
169156
Application.delete_env(:check_repo_ready, :ecto_repos)
170157
Process.unregister(StorageUpRepo)

0 commit comments

Comments
 (0)