feat(db): GRO-2722 schema-safe reset — TRUNCATE, no DROP (uat → main) #242

Closed
Flea Flicker wants to merge 0 commits from uat into main
Member

GRO-2722 — Schema-safe reset (TRUNCATE, no DROP)

Promotes uat → main after all Phase 3 gates passed.

Changes

  • packages/db/src/reset.ts — replaced four destructive DO-blocks (DROP TABLE, DROP TYPE, DROP SCHEMA, DROP DATABASE) with a single TRUNCATE <all public tables> RESTART IDENTITY CASCADE
  • apps/api/src/db/reset.ts — same replacement for the API-layer reset path
  • Tables enumerated dynamically via pg_tables WHERE schemaname='public'; identifiers double-quoted with embedded-quote escaping
  • drizzle schema and __drizzle_migrations excluded from TRUNCATE
  • Production guard (NODE_ENV===production && ALLOW_RESET!=='true'), advisory lock, migrations, and seed all preserved
  • UAT_PLAYBOOK.md §3 — new TC-API-3.30 covering schema-safe reset verification

SDLC gates satisfied

  • Phase 1: CI passed on feature branch → merged to dev
  • Phase 2: QA approved (Lint Roller) → merged dev → uat
  • Phase 3 UAT: Shedward Scissorhands — PASS (GRO-2723)
  • Phase 3 Security: Barkley Trimsworth — PASS (GRO-2726); no SQL injection risk, production guard intact, no privilege escalation
  • Updated UAT_PLAYBOOK.md §3 (TC-API-3.30)

cc @cpfarhood

## GRO-2722 — Schema-safe reset (TRUNCATE, no DROP) Promotes uat → main after all Phase 3 gates passed. ### Changes - `packages/db/src/reset.ts` — replaced four destructive DO-blocks (`DROP TABLE`, `DROP TYPE`, `DROP SCHEMA`, `DROP DATABASE`) with a single `TRUNCATE <all public tables> RESTART IDENTITY CASCADE` - `apps/api/src/db/reset.ts` — same replacement for the API-layer reset path - Tables enumerated dynamically via `pg_tables WHERE schemaname='public'`; identifiers double-quoted with embedded-quote escaping - `drizzle` schema and `__drizzle_migrations` excluded from TRUNCATE - Production guard (`NODE_ENV===production && ALLOW_RESET!=='true'`), advisory lock, migrations, and seed all preserved - `UAT_PLAYBOOK.md §3` — new TC-API-3.30 covering schema-safe reset verification ### SDLC gates satisfied - Phase 1: CI passed on feature branch → merged to dev - Phase 2: QA approved (Lint Roller) → merged dev → uat - Phase 3 UAT: Shedward Scissorhands — PASS (GRO-2723) - Phase 3 Security: Barkley Trimsworth — PASS (GRO-2726); no SQL injection risk, production guard intact, no privilege escalation - Updated `UAT_PLAYBOOK.md §3` (TC-API-3.30) cc @cpfarhood
Flea Flicker added 4 commits 2026-08-16 13:36:53 +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
dev → uat: GRO-2722 schema-safe reset (TRUNCATE, no DROP)
CI / Test (push) Failing after 3s
CI / Lint & Typecheck (push) Successful in 20s
CI / Build & Push Docker Images (push) Has been skipped
CI / Lint & Typecheck (pull_request) Successful in 17s
CI / Test (pull_request) Successful in 51s
CI / Build & Push Docker Images (pull_request) Successful in 34s
8b812dfd22
Merged after QA (Lint Roller) approval on Gitea. All 6 CI contexts green on 38380d0.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Flea Flicker requested review from Scrubs McBarkley 2026-08-16 13:37:08 +00:00
Flea Flicker closed this pull request 2026-08-16 13:41:14 +00:00
Some checks are pending
CI / Test (push) Failing after 3s
CI / Lint & Typecheck (push) Successful in 20s
CI / Build & Push Docker Images (push) Has been skipped
CI / Lint & Typecheck (pull_request) Successful in 17s
CI / Test (pull_request) Successful in 51s
CI / Build & Push Docker Images (pull_request) Successful in 34s

Pull request closed

Sign in to join this conversation.