feat(db): drizzle setup + nuke 17 hand-rolled migrations #854

Merged
reviewer merged 2 commits from code-lead/839 into main 2026-05-04 21:25:35 +00:00
Collaborator

Foundation for the ORM-migration milestone — ensureSchema now applies a checked-in 0000_init.sql snapshot via a Drizzle-style runner, and the 17 hand-rolled runXxxMigration files are gone.

Test plan

  • bun x turbo run typecheck — clean
  • bun test — 3101 pass, 0 fail (added migrate.test.ts: bootstrap equivalence, idempotency, assume-up-to-date branch, per-DB filename filtering)
  • just db-check — agents + tasks both ok
  • biome format clean on touched files
  • post-merge: operator wipes ~/.local/state/claude-hooks/{agents,tasks}.db before deploying, per the AC

Closes #839

Foundation for the ORM-migration milestone — `ensureSchema` now applies a checked-in `0000_init.sql` snapshot via a Drizzle-style runner, and the 17 hand-rolled `runXxxMigration` files are gone. ## Test plan - [x] `bun x turbo run typecheck` — clean - [x] `bun test` — 3101 pass, 0 fail (added `migrate.test.ts`: bootstrap equivalence, idempotency, assume-up-to-date branch, per-DB filename filtering) - [x] `just db-check` — agents + tasks both ok - [x] biome format clean on touched files - [ ] post-merge: operator wipes `~/.local/state/claude-hooks/{agents,tasks}.db` before deploying, per the AC Closes #839
feat(db): drizzle setup + nuke 17 hand-rolled migrations (#839)
Some checks failed
qa / db-schema (pull_request) Failing after 10s
qa / dockerfile (pull_request) Successful in 25s
qa / qa-1 (pull_request) Successful in 2m36s
qa / qa (pull_request) Successful in 0s
315be5ca05
Wipe-and-reseed foundation for the ORM-migration milestone. ensureSchema
now applies a checked-in 0000_init.sql snapshot via a Drizzle-style
runner; the 17 runXxxMigration files are gone.

- drizzle-orm + drizzle-kit on apps/server, drizzle.config.ts at repo
- snake_case TS field convention (bridge style — no caller renames)
- apps/server/src/infrastructure/database/migrate.ts: applyMigrations()
  reads drizzle/*.sql, filters by *_tasks.sql suffix per DB, tracks
  applied set in __drizzle_migrations
- 0000_init.sql + 0000_init_tasks.sql captured from live ensureSchema
- "assume up-to-date" branch when sentinel table already present
- runPromoteOauthEnvToDb relocated to setup/oauth-env-bootstrap.ts
- AOI-5 prune count + boot logging removed
- just db-snapshot / db-generate / db-check; CI db-schema job
- docs/database.md describes layout + workflow + wipe contract
- migrate.test.ts asserts bootstrap equivalence with ensureSchema()

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix(ci): drop apt-install of just — base image already has it
All checks were successful
qa / db-schema (pull_request) Successful in 34s
qa / dockerfile (pull_request) Successful in 59s
qa / qa-1 (pull_request) Successful in 1m14s
qa / qa (pull_request) Successful in 0s
f7dc4f78fd
`forge-base/bun:v0.2.2` ships `just` as a pinned binary
(see forge-base/docker/bun.Dockerfile). `just` is not a Debian
bookworm package, so `apt-get install … just` failed with
"unable to locate package just" and the db-schema job died at
~10s before reaching `actions/checkout`.

The dockerfile job uses the same base image and apt-installs
only `nodejs`; mirror that here.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
reviewer approved these changes 2026-05-04 21:25:26 +00:00
reviewer left a comment

All AC met. Migration runner is clean: sentinel-table "assume up-to-date" branch correctly handles pre-Drizzle live DBs without re-firing CREATE TABLE. Tests cover bootstrap equivalence, idempotency, assume-up-to-date, and per-DB filtering. CI green on all 4 jobs.

Nit (non-blocking): as unknown as never[] cast in migrate.ts:117 is a Bun SQLite API workaround — acceptable but worth noting for future cleanup.

All AC met. Migration runner is clean: sentinel-table "assume up-to-date" branch correctly handles pre-Drizzle live DBs without re-firing CREATE TABLE. Tests cover bootstrap equivalence, idempotency, assume-up-to-date, and per-DB filtering. CI green on all 4 jobs. Nit (non-blocking): `as unknown as never[]` cast in `migrate.ts:117` is a Bun SQLite API workaround — acceptable but worth noting for future cleanup.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!854
No description provided.