Skip to content

Commit 585c2d1

Browse files
committed
Consider prefix when locking table, closes #342
1 parent bfa697c commit 585c2d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/ecto/adapters/postgres.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ defmodule Ecto.Adapters.Postgres do
217217
# itself but still allows updates to happen, see
218218
# # https://www.postgresql.org/docs/9.4/explicit-locking.html
219219
source = Keyword.get(opts, :migration_source, "schema_migrations")
220-
{:ok, _} = Ecto.Adapters.SQL.query(meta, "LOCK TABLE \"#{source}\" IN SHARE UPDATE EXCLUSIVE MODE", [], opts)
220+
table = if prefix = opts[:prefix], do: ~s|"#{prefix}"."#{source}"|, else: ~s|"#{source}"|
221+
{:ok, _} = Ecto.Adapters.SQL.query(meta, "LOCK TABLE #{table} IN SHARE UPDATE EXCLUSIVE MODE", [], opts)
221222
fun.()
222223
end)
223224

0 commit comments

Comments
 (0)