fix(GRO-2672): use drizzle-kit migrate in reset.ts to bypass HWM bug
drizzle-orm/postgres-js/migrator's migrate() has the known high-water-mark
bug (GRO-1999/2033): on a fresh DB it applies migration 0000 first, setting
the watermark to its `when` timestamp (1773771452946, 2026-03-17). Migrations
0001, 0003, 0010, 0011 all have stale 2025-era `when` values that fall below
this watermark and are silently skipped.
Migration 0003 (recurring_series) is the critical skip: it creates the
`recurring_series` table and adds `series_id`/`series_index` columns to
`appointments`. Since migrate() wraps all SQL in a single Postgres transaction,
any downstream applied migration that depends on those missing objects causes
a full transaction rollback — including migration 0000's staff and services
tables. The result: every reset-demo-data run since the 552a4d9 deploy leaves
the DB with zero tables, causing both reset-demo-data and seed-test-data jobs
to fail on every subsequent run.
Fix: replace migrate() from drizzle-orm with `pnpm exec drizzle-kit migrate`
(hash-based, same as the K8s migrate Job). drizzle-kit applies every unhashed
migration regardless of its `when` timestamp ordering, matching the K8s migrate
Job's behaviour exactly.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
+1
-145
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user