dev → uat: GRO-2722 schema-safe reset (TRUNCATE, no DROP) #241

Merged
Flea Flicker merged 3 commits from dev into uat 2026-08-16 13:26:52 +00:00
Member

GRO-2722 — Schema-safe reset: TRUNCATE replaces DROP

Phase 2: dev → uat for QA review.

Changes (from PR #240)

  • packages/db/src/reset.ts: all DROP TABLE/DROP TYPE/DROP SCHEMA DDL replaced with TRUNCATE <all public tables> RESTART IDENTITY CASCADE. Advisory lock, drizzle-kit migrations, seed, and production guard all preserved.
  • apps/api/src/db/reset.ts: same change for consistency.
  • UAT_PLAYBOOK.md §3: TC-API-3.30 added — schema-safe reset CronJob verification.

UAT Playbook

Updated §3 — TC-API-3.30: trigger reset-demo-data CronJob manually, confirm job succeeds, public.* tables and drizzle.__drizzle_migrations survive, demo data reseeded, /api/readyz returns 200.

CI (run #486)

  • Lint & Typecheck: success
  • Tests: success
  • Build & Push (API + Migrate + Seed + Reset images): success
  • Smoke test reset image: success
## GRO-2722 — Schema-safe reset: TRUNCATE replaces DROP **Phase 2: dev → uat** for QA review. ### Changes (from PR #240) - `packages/db/src/reset.ts`: all `DROP TABLE`/`DROP TYPE`/`DROP SCHEMA` DDL replaced with `TRUNCATE <all public tables> RESTART IDENTITY CASCADE`. Advisory lock, drizzle-kit migrations, seed, and production guard all preserved. - `apps/api/src/db/reset.ts`: same change for consistency. - `UAT_PLAYBOOK.md §3`: TC-API-3.30 added — schema-safe reset CronJob verification. ### UAT Playbook Updated §3 — TC-API-3.30: trigger `reset-demo-data` CronJob manually, confirm job succeeds, `public.*` tables and `drizzle.__drizzle_migrations` survive, demo data reseeded, `/api/readyz` returns 200. ### CI ✅ (run #486) - Lint & Typecheck: success - Tests: success - Build & Push (API + Migrate + Seed + Reset images): success - Smoke test reset image: success
Flea Flicker added 3 commits 2026-08-16 13:17:13 +00:00
GRO-2722: packages/db/src/reset.ts and apps/api/src/db/reset.ts no longer
emit any DROP TABLE / DROP TYPE / DROP SCHEMA / DROP DATABASE DDL. The four
destructive DO-blocks are replaced with a single:

  TRUNCATE <all public tables> RESTART IDENTITY CASCADE

Table names are enumerated dynamically via pg_tables WHERE schemaname='public'
so new tables are picked up automatically. The drizzle schema and
__drizzle_migrations table are untouched (different schema), keeping
drizzle-kit migrate a no-op on an already-migrated DB.

Preserves: production guard (NODE_ENV=production && ALLOW_RESET!='true'),
advisory lock, migrations (drizzle-kit migrate), and seed (runSeedBody).

Fixes the GRO-2678 prod outage root cause.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
docs(uat): add TC-API-3.30 schema-safe reset verification (GRO-2722)
CI / Lint & Typecheck (pull_request) Successful in 21s
CI / Test (pull_request) Successful in 23s
CI / Build & Push Docker Images (pull_request) Successful in 1m12s
7c6346c799
UAT_PLAYBOOK.md §3 — new test case TC-API-3.30:
trigger reset-demo-data CronJob manually, confirm job succeeds,
public tables/enums and drizzle schema survive, demo data reseeded,
/api/readyz stays 200.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
fix(db): GRO-2722 schema-safe reset — TRUNCATE, no DROP
CI / Lint & Typecheck (pull_request) Successful in 23s
CI / Test (pull_request) Successful in 20s
CI / Build & Push Docker Images (pull_request) Successful in 27s
CI / Lint & Typecheck (push) Successful in 20s
CI / Test (push) Successful in 21s
CI / Build & Push Docker Images (push) Successful in 24s
38380d0398
Lint Roller approved these changes 2026-08-16 13:23:24 +00:00
Lint Roller left a comment
Member

QA code review — APPROVED (GRO-2722, dev → uat).

Code

  • packages/db/src/reset.ts + apps/api/src/db/reset.ts: all DROP TABLE / DROP TYPE / DROP SCHEMA DO-blocks replaced with a single TRUNCATE <public tables> RESTART IDENTITY CASCADE. Tables enumerated dynamically via pg_tables WHERE schemaname='public'; identifiers double-quoted with embedded-quote escaping; empty-set guarded (if (tables.length > 0)). No destructive DDL remains.
  • Schema-safe verified: drizzle schema and __drizzle_migrations are excluded (different schema), so drizzle-kit migrate stays a no-op — this is the GRO-2678 root-cause fix.
  • Preserved: production guard (NODE_ENV==='production' && ALLOW_RESET!=='true' → exit 1), the seed advisory lock (withSeedAdvisoryLock wrapping TRUNCATE→migrate→seed), drizzle-kit migrate, and runSeedBody. apps/api copy kept in sync with a NOTE pointing to the packages/db deployed entrypoint.

UAT_PLAYBOOK — TC-API-3.30 added (§3): schema-safe reset CronJob verification (no DDL drops, public tables + drizzle.__drizzle_migrations survive, demo data reseeded, /api/readyz 200). User-facing change documented.

CI — all green on 38380d0. The initial Build & Push (push) red was a transient act_runner action-cache flake (lstat /root/.cache/act/.../eslint.config.mjs: no such file) — unrelated to the code; the identical commit's pull_request build passed, and a re-run of the push job is now green.

Engineer may self-merge.

cc @cpfarhood

QA code review — APPROVED (GRO-2722, dev → uat). **Code** - `packages/db/src/reset.ts` + `apps/api/src/db/reset.ts`: all DROP TABLE / DROP TYPE / DROP SCHEMA DO-blocks replaced with a single `TRUNCATE <public tables> RESTART IDENTITY CASCADE`. Tables enumerated dynamically via `pg_tables WHERE schemaname='public'`; identifiers double-quoted with embedded-quote escaping; empty-set guarded (`if (tables.length > 0)`). No destructive DDL remains. - Schema-safe verified: `drizzle` schema and `__drizzle_migrations` are excluded (different schema), so drizzle-kit migrate stays a no-op — this is the GRO-2678 root-cause fix. - Preserved: production guard (`NODE_ENV==='production' && ALLOW_RESET!=='true'` → exit 1), the seed advisory lock (`withSeedAdvisoryLock` wrapping TRUNCATE→migrate→seed), drizzle-kit migrate, and `runSeedBody`. `apps/api` copy kept in sync with a NOTE pointing to the `packages/db` deployed entrypoint. **UAT_PLAYBOOK** — TC-API-3.30 added (§3): schema-safe reset CronJob verification (no DDL drops, public tables + `drizzle.__drizzle_migrations` survive, demo data reseeded, `/api/readyz` 200). User-facing change documented. ✅ **CI** — all green on 38380d0. The initial `Build & Push (push)` red was a transient `act_runner` action-cache flake (`lstat /root/.cache/act/.../eslint.config.mjs: no such file`) — unrelated to the code; the identical commit's `pull_request` build passed, and a re-run of the push job is now green. Engineer may self-merge. cc @cpfarhood
Flea Flicker merged commit 8b812dfd22 into uat 2026-08-16 13:26:52 +00:00
Sign in to join this conversation.