Bring the migration snapshot back in step with the schema - #93
Bring the migration snapshot back in step with the schema#93NathanTarbert wants to merge 1 commit into
Conversation
…otKit#91) Two fields moved in core.ts in CopilotKit#87 and meta/0005_snapshot.json was not regenerated, so drizzle-kit generate kept writing a migration nobody asked for and the migrations drift probe kept failing on the dirty tree, on main and on every branch cut from it. The emitted DDL is a no-op against any deployment. accounts.issuer is absent from 0000_schema.sql, added nullable by 0002_sign_in.sql and filled by 0003, and SET NOT NULL was never applied, so DROP NOT NULL drops a constraint that is not there. 0004 already dropped and re-added the sso_providers foreign key with ON DELETE set null, so re-landing it lands it on the constraint it has. The file says all of that at the top, so nobody later goes looking for the schema change it was written for. drizzle-kit check passes and generate now reports no changes, which is what the probe asserts.
|
Superseded, and only by minutes: #90 landed the same repair at 17:54 and you opened this at 17:44, so we were both on it without knowing. Sorry for the wasted work. Your diagnosis is the better-written one and it is right in a detail mine glossed: the DDL really is a no-op, because You also reached the same conclusion on the alternative, which is worth recording: regenerating beats hand-editing Closing this one rather than #90 only because #90 was already merged and carries six other fixes with it. |
What this changes
Regenerates the drizzle snapshot so it agrees with
core.tsagain, which gets themigrationsjob green.Fixes #91.
Two fields moved in
server/src/db/schema/core.tsin #87 andmeta/0005_snapshot.jsonwas not regenerated alongside them, sodrizzle-kit generatehas been writing a migration nobody asked for and the drift probe has been failing on the dirty tree — onmain, and on every branch cut from it since.core.tsmeta/0005_snapshot.jsonbefore thisaccounts.issuer:92)notNull: truesso_providers.user_idFKon delete set null(:169)cascadeThe DDL is a no-op, and that is the point worth reviewing
The three statements look like a schema change and are not one. No deployment is in the state the old snapshot described:
accounts.issuerdoes not appear in0000_schema.sqlat all.0002_sign_in.sql:19adds it nullable,0003_backfill_account_issuer.sqlfills it, andSET NOT NULLwas never applied anywhere.DROP NOT NULLtherefore drops a constraint that does not exist, which Postgres accepts.0004_identity_provider_outlives_its_registrar.sqlalready dropped and re-added thesso_providersforeign key withON DELETE set null. Re-landing it puts it back on the constraint it already has.The migration file opens with a comment saying exactly that, so nobody reading
drizzle/later goes hunting for the schema change it was written for.Editing
meta/0005_snapshot.jsonby hand was the alternative and would have avoided the pointless DDL. Regenerating won because it is the tool's own output rather than a hand-edit of a generated file, and because0006leaves a readable record of when the two came back into agreement. Happy to switch if you would rather the snapshot were repaired in place.Where it runs
drizzle-kit migratestep every other one does.Boundary and audit
Changelog
No line. A deployment behaves identically afterwards — the statements are no-ops and there is nothing for an operator to do or know.
Proof
Both steps the
migrationsjob runs, reproduced locally against this branch:The probe writes nothing now, so the tree stays clean and the job passes. On
mainthe same command writes a file, which is the failure.The generated
meta/0006_snapshot.jsonand_journal.jsonneededbiome formatbeforeformat:checkwould pass, matching how the existing snapshots indrizzle/metaare stored. Formatting them does not reintroduce drift — the probe was re-run afterwards and still reports no changes.Rest of the suite:
bun run format:check— clean, 364 files.bun run lint— 27 warnings, 1 info, identical to unmodifiedmain.bun run typecheck— clean across app, server and worker.bun test— 780 pass, 5 skip, 79 fail, 864 tests across 91 files, exactly the unmodifiedmainbaseline on this machine. The 79 are the database integration tests, which need a Postgres this machine does not have and fail the same way on a cleanmain; the CItestsjob runs pgvector for them.Worth landing before #92 and the fix for #88 item 1, since both are sitting red on this same inherited check.
One thing for a separate conversation
The drift probe caught this when it happened and the merge went through anyway, so there may be a required-check setting to look at. That is a repo setting rather than a code change, so it is not in this PR.