mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
fix(migrations): bound the lock wait of 0475 and 0480, and of every file after
0475 and 0480 added their columns with a bare ALTER TABLE, which waits for its table lock behind every open transaction while every write to the table queues behind it. Both now run in a DO block with a five second lock_timeout and carry the boot's retry marker; the effect is the same and both stay safe to run again. Neither has shipped in a release. A database that already applied them is unaffected: prisma migrate deploy and migrate status ignore the checksum of an applied migration (checked against a database migrated with the old files), so nothing is re-run and nothing is reported. The lock-timeout guard now refuses, from 0475 on, any statement that takes a table lock outside such a block.
This commit is contained in:
1 parent
205d8f257c
commit
b2c99e5c8d
3 files changed
+91
-3
No files matched your search
@@ -10,5 +10,16 @@
|
||||
--
|
||||
-- Reversibility: dropping the column loses only that marker; the scores and
|
||||
-- the encrypted answers do not depend on it.
|
||||
--
|
||||
-- The lock wait is bounded inside a DO block and the file is safe to run
|
||||
-- again, so the boot retries it on a lock timeout.
|
||||
--
|
||||
-- @retry-on-lock-timeout
|
||||
|
||||
ALTER TABLE "mental_health_assessments" ADD COLUMN IF NOT EXISTS "wording" TEXT;
|
||||
DO $migration$
|
||||
BEGIN
|
||||
PERFORM set_config('lock_timeout', '5s', true);
|
||||
ALTER TABLE "mental_health_assessments"
|
||||
ADD COLUMN IF NOT EXISTS "wording" TEXT;
|
||||
END
|
||||
$migration$;
|
||||
@@ -7,5 +7,16 @@
|
||||
-- up to two hours. A written or re-dated note resets it to zero.
|
||||
--
|
||||
-- Existing rows start at zero, which is the five-minute window they had.
|
||||
ALTER TABLE "insight_status_caches"
|
||||
ADD COLUMN IF NOT EXISTS "failure_streak" INTEGER NOT NULL DEFAULT 0;
|
||||
--
|
||||
-- The lock wait is bounded inside a DO block and the file is safe to run
|
||||
-- again, so the boot retries it on a lock timeout.
|
||||
--
|
||||
-- @retry-on-lock-timeout
|
||||
|
||||
DO $migration$
|
||||
BEGIN
|
||||
PERFORM set_config('lock_timeout', '5s', true);
|
||||
ALTER TABLE "insight_status_caches"
|
||||
ADD COLUMN IF NOT EXISTS "failure_streak" INTEGER NOT NULL DEFAULT 0;
|
||||
END
|
||||
$migration$;
|
||||
Reference in new issue
Block a user