Files
website/db/reorg/README.md
Stan Runge 64fb8df262 db: Drizzle schemas on domain Postgres schemas, baseline migration, reorg SQL
- pgSchema tables for auth, money, house, ref, games, cs, animaldex, site, meta
  (lists excluded via schemaFilter; runtime list tables are managed by meta.*)
- drizzle/ baseline matches the reorged DB exactly (catalog diff = 0 on rehearsal)
- db/reorg: one-time SQL that moves the flat public schema (rehearsed on a prod copy)
- scripts/db-migrate.ts: migrator with --init to record the baseline and a guard
  against running the baseline on a non-empty, unrecorded database
2026-10-23 22:03:42 +00:00

22 lines
1.2 KiB
Markdown

# One-time schema reorg (2026-10)
Hand-written, reviewed SQL that moved the old flat `public.*` tables into the
domain schemas (`auth`, `money`, `house`, `ref`, `games`, `cs`, `animaldex`,
`site`, `meta`, `lists`, `hardware`, `energy`, `legacy`), created the roles
(`personal`, `personal_app`, `personal_ddl`, `personal_ro`), the `meta.*`
registry/API and the 22 runtime lists. It is the state that the Drizzle baseline
in `drizzle/` describes.
These files are kept for the record and for the cutover only. They were
rehearsed on a copy of prod (PG17) and run in one transaction (`run.sh`,
which refuses the real database names unless `ALLOW_REAL=yes`). After the
cutover, record the baseline with `bun scripts/db-migrate.ts --init`; from then
on every schema change is a normal Drizzle migration (`bun run db:generate`).
Passwords are never in these files; set them with `\password` in psql.
`09_drizzle_names.sql` runs just before `08_verify.sql` and only renames 48
constraints and 5 indexes to Drizzle's generated names, so a catalog diff of the
reorged DB against a DB built from the baseline is empty (columns, defaults,
constraints, indexes, enums in the nine Drizzle schemas).