Skip to content

PhoenixKit 2.13.11: The V180 migration no longer crashes

PhoenixKit 2.13.11 fixes migration V180, which stopped every upgrade to versions 2.13.4 through 2.13.10 with LOCK TABLE can only be used in transaction blocks. Every install was affected, not only sites using the catalogue, because the table it locks always exists.

The lock, the clean-up of duplicate supplier rows and the new unique index now run together in one block, so the lock also protects the steps it was meant to. The clean-up also wrote the closing time on those rows hours off when the database session was not on UTC; it now writes the right time.

Upgrading

Upgrade straight to this version and run mix phoenix_kit.update (or mix ecto.migrate). If V180 already crashed on your install, the first half of it was saved and the version still reads V179, so a plain re-run completes it.

Full release notes: PhoenixKit 2.13.11

2.13.11 · 25 August 2026

Every install migrating through V180 crashed outright — a bare LOCK TABLE statement outside a transaction block, 25P01 no_active_sql_transaction. Not only apps using the catalogue module: the table V180 locks is created unconditionally by the chain (V149, and the V135 floor), so every release from 2.13.4 through 2.13.10 is affected. Upgrade straight to this one.

Fixed

  • V180 (enforce_one_current_supplier_per_pair/2) crashed every install with Postgrex.Error: LOCK TABLE can only be used in transaction blocks. Migration wrappers carry @disable_ddl_transaction true (core convention — every generated wrapper does this so a long DDL statement isn’t held inside one giant transaction), so each top-level execute/1 auto-commits on its own and a bare LOCK TABLE has no transaction to hold. Even accepted, the lock would have released at its own commit — before the UPDATE and CREATE UNIQUE INDEX it existed to protect, leaving the concurrent-writer race it was written to close still open. Lock, dedupe UPDATE, and CREATE UNIQUE INDEX now run inside one DO $$ block, same shape V170 already used for phoenix_kit_notifications_dedupe_unseen_idx. Recovery for an install that hit the crash: block 1 of V180 (the manufacturer/supplier federation columns) already committed, and the version comment still reads '179', so a plain re-run (mix ecto.migrate / mix phoenix_kit.update) completes it — every block-1 statement is IF NOT EXISTS-guarded.
  • V180’s dedupe wrote updated_at off by the session’s UTC offset. now() AT TIME ZONE 'utc' is the right idiom for core’s timestamp without time zone columns, but phoenix_kit_cat_item_supplier_info declares TIMESTAMPTZ (V149): the expression yields a UTC wall clock that the assignment then re-reads in the session time zone, so a host on America/New_York stamped the closed rows four hours in the future. Bare now() now, as V170’s dedupe already used. Only rows this migration closes were affected.

Added

  • Static chain check: no LOCK TABLE outside a DO $$ block. lock_table_guard_test.exs already asserted that every LOCK TABLE sits behind a table-existence guard, but it only ever looked inside DO $$ bodies — a bare top-level one was invisible to it, which is how V180 shipped. Nothing else in the suite can catch this class either: PhoenixKit.Migration.Runner carries no @disable_ddl_transaction, so ensure_current/2 (and therefore test_helper.exs, and the full-chain prefix test) runs migrations inside a transaction — the one condition under which a bare LOCK TABLE succeeds.

PhoenixKit 2.13.11. Install or update: {:phoenix_kit, "~> 2.13"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.