From 138792d5553adc53b3eae216dd5f8d9a75a615e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 11 Oct 2026 13:50:30 +0200 Subject: [PATCH] docs(db): correct the build cost note on the noted-readings index migration --- .../0397_measurements_noted_live_idx/migration.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/prisma/migrations/0397_measurements_noted_live_idx/migration.sql b/prisma/migrations/0397_measurements_noted_live_idx/migration.sql index 20711fc33..de777e276 100644 --- a/prisma/migrations/0397_measurements_noted_live_idx/migration.sql +++ b/prisma/migrations/0397_measurements_noted_live_idx/migration.sql @@ -8,8 +8,13 @@ -- -- Additive only, no table rewrite, no data change. Non-concurrent for the -- reason migration 0243 gives: Prisma Migrate runs a migration file in a --- transaction, and the entrypoint applies migrations before the app serves --- traffic. The predicate is tiny, so the build is short. +-- transaction. The build is not short on a large instance: the predicate +-- only decides which rows land in the index, so Postgres still scans the +-- whole `measurements` table to find them, and the non-concurrent build +-- blocks writes to the table while it runs. That is acceptable because the +-- entrypoint applies migrations before the app serves traffic, so no request +-- is waiting on those writes; an upgrade on a table with many millions of +-- readings simply takes longer to come up. CREATE INDEX IF NOT EXISTS "measurements_noted_live_idx" ON "measurements" ("user_id", "measured_at" DESC, "id" DESC) WHERE "deleted_at" IS NULL