fix(db): repair migration chain so it applies cleanly on a fresh DB
Commit notes
The drizzle-generated 0004 migration re-creates every object already made by the hand-written 0001-0003 migrations (umap columns, guest packs, subscription enums/tables) without idempotency guards, so the chain died on the first CREATE TYPE when run in order against an empty database — failing the CI 'Apply database migrations' step before any test could run. - 0004: guard every statement (DO blocks for enums/constraints, IF NOT EXISTS for tables/columns/indexes) so it is a clean no-op once 0001-0003 have run. - 0013 + schema.ts: projects.created_by was NOT NULL but its FK used ON DELETE SET NULL — deleting a user violated the not-null constraint and broke the DB-backed auth suite's cascade cleanup. Switch to ON DELETE CASCADE to match the documented intent and the sibling patterns.created_by FK. Verified: full chain applies on a bare pgvector:pg16 database (22/22 migrations) and 'bun test' passes 176/0 with DATABASE_URL/REDIS_URL set. [private session redacted]
- Files
- 3
- Added
- +51
- Removed
- −26