build(agent-daemon-state): adopt Drizzle migrations (issue #1293 PR1)#1405
Open
legreffier[bot] wants to merge 1 commit into
Open
build(agent-daemon-state): adopt Drizzle migrations (issue #1293 PR1)#1405legreffier[bot] wants to merge 1 commit into
legreffier[bot] wants to merge 1 commit into
Conversation
…FKs/CHECK Replace hand-rolled inline CREATE TABLE IF NOT EXISTS (SQLite + Postgres) with drizzle-kit-generated baselines and a src/migrate.ts. SQLite applies the baseline synchronously via client.exec (proxy driver has no file migrator, store ctor is sync); Postgres uses the node-postgres migrator. Add composite ON DELETE CASCADE FKs, the state CHECK, and DESC index ordering to schema.ts/pg-schema.ts so the generated SQL reproduces the live DDL exactly. No behavior change. PR1 of #1293. MoltNet-Diary: c581217c-3cbd-4d61-bf9f-f32371d90d33 Task-Group: daemon-state-drizzle-migrations Task-Family: infra Task-Completes: true
Contributor
|
Contributor
🚨 Dependency Audit — Vulnerabilities foundFull report |
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PR1 of #1293. Adopts Drizzle migrations for the
agent-daemon-stateDB, replacing hand-rolled inlineCREATE TABLE IF NOT EXISTS(both SQLite and Postgres). No behavior change — this is the migration foundation before the refcounted-workspace refactor (PR2) that actually implements fork mode.Why
libs/agent-daemon-statewas the one DB lib never converted during the Drizzle migration — it bootstrapped its schema with raw SQL inline indaemon-slot-registry.ts, with no drizzle-kit config or migrator. While adopting Drizzle, diffing the generated baseline against the inline DDL surfaced that the Drizzle schema files under-declared the live schema:ON DELETE CASCADEondaemon_slot_sessions/daemon_slot_workspaces→daemon_slots. Load-bearing:reapExpiredSlotsdeletes only fromdaemon_slotsand relies on cascade to clean up dependent rows. Without it, reaping orphans rows.stateCHECK (state IN ('active','idle'))constraint.last_used_at_ms DESCindex ordering ondaemon_slots_task_attempt_idx.All three are now declared so the generated baseline reproduces the inline DDL exactly.
How
drizzle.config.sqlite.ts+drizzle.config.pg.ts(dual-dialect; the runtime selects SQLite vianode:sqliteproxy or Postgres).drizzle-sqlite/,drizzle-pg/).src/migrate.ts:client.exec(the store constructor is sync and the proxy driver has no file migrator), tracked for idempotency.node-postgresmigrator (tracked, transactional).CREATE TABLEblocks; both store constructors now call the migrators.Verification
daemon-slot-registry.test.tspasses unchanged (behavior equivalence).migrate.test.tsproves the baseline creates all tables and that cascade delete and the CHECK constraint are actually enforced.drizzle-kit generatereports "No schema changes" → baselines match the schema with zero drift.agent-daemon-stateand the consumingagent-daemon.MoltNet-Diary: c581217c-3cbd-4d61-bf9f-f32371d90d33