dev → uat: GRO-2722 schema-safe reset (TRUNCATE, no DROP) #241
Reference in New Issue
Block a user
Delete Branch "dev"
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?
GRO-2722 — Schema-safe reset: TRUNCATE replaces DROP
Phase 2: dev → uat for QA review.
Changes (from PR #240)
packages/db/src/reset.ts: allDROP TABLE/DROP TYPE/DROP SCHEMADDL replaced withTRUNCATE <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-dataCronJob manually, confirm job succeeds,public.*tables anddrizzle.__drizzle_migrationssurvive, demo data reseeded,/api/readyzreturns 200.CI ✅ (run #486)
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 singleTRUNCATE <public tables> RESTART IDENTITY CASCADE. Tables enumerated dynamically viapg_tables WHERE schemaname='public'; identifiers double-quoted with embedded-quote escaping; empty-set guarded (if (tables.length > 0)). No destructive DDL remains.drizzleschema and__drizzle_migrationsare excluded (different schema), so drizzle-kit migrate stays a no-op — this is the GRO-2678 root-cause fix.NODE_ENV==='production' && ALLOW_RESET!=='true'→ exit 1), the seed advisory lock (withSeedAdvisoryLockwrapping TRUNCATE→migrate→seed), drizzle-kit migrate, andrunSeedBody.apps/apicopy kept in sync with a NOTE pointing to thepackages/dbdeployed entrypoint.UAT_PLAYBOOK — TC-API-3.30 added (§3): schema-safe reset CronJob verification (no DDL drops, public tables +
drizzle.__drizzle_migrationssurvive, demo data reseeded,/api/readyz200). User-facing change documented. ✅CI — all green on
38380d0. The initialBuild & Push (push)red was a transientact_runneraction-cache flake (lstat /root/.cache/act/.../eslint.config.mjs: no such file) — unrelated to the code; the identical commit'spull_requestbuild passed, and a re-run of the push job is now green.Engineer may self-merge.
cc @cpfarhood