fix(db): GRO-2722 schema-safe reset — TRUNCATE, no DROP #240
Reference in New Issue
Block a user
Delete Branch "flea/gro-2721-schema-safe-reset"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
GRO-2722 — rewrite
packages/db/src/reset.tsto be schema-safe for prod.Root cause recap
GRO-2678 prod outage:
reset.tsissuedDROP TABLE ... CASCADEfor every public table, thenDROP SCHEMA drizzle CASCADE. The subsequentdrizzle-kit migrateno-op'd on an empty DB → outage.Changes
packages/db/src/reset.ts(the deployed image entrypoint —pnpm --filter @groombook/db reset):DROP-based DO-blocks (DROP TABLE loop, DROP TYPE loop, DROP drizzle migrations, DROP drizzle schema) with a single:pg_tables WHERE schemaname='public'.drizzleschema and__drizzle_migrationsare in a different schema — excluded automatically, drizzle-kit migrate stays a no-op.apps/api/src/db/reset.ts(dev-only artifact, not shipped — delegates to packages/db):UAT_PLAYBOOK.md§3 — added TC-API-3.30: manual CronJob trigger, schema-survival check, /api/readyz 200 verification.Acceptance criteria
grep -iE 'DROP (TABLE|TYPE|SCHEMA|DATABASE)' packages/db/src/reset.ts→ no outputreset.tsusesTRUNCATE ... RESTART IDENTITY CASCADENODE_ENV=production && ALLOW_RESET!='true')cc @cpfarhood