Repository navigation
chore(database): one migration builds the schema, since the move wipes every database - #532
Conversation
…s every database
piqueld's only instance is being moved and its data wiped, so no database
needs the history of 50 migrations. 0001_initial.sql now creates the final
schema directly, with comments that describe it as it is.
What only old rows needed goes with it: NULL digest keys ("unrecorded"),
the legacy invitation ID default, the imported audit-log event and its
unrecorded actor, the signing key "imported" change, and audit chain
format 1. The one chain format is now format 1, which names itself.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Council round 1: the citations of migrations 0006, 0035 and 0042 that remained, the trace ID and imported-key wording, and where the migration test helpers went.
Council round 2: limit_passkeys guards passkeys, not the chain, and two comments still described a release that no longer exists.
piqueld's only instance is being shut down and moved, and all its data wiped. Nothing needs 50 migrations of history any more, nor the code that read rows only those migrations wrote. Now one
0001_initial.sqlbuilds the final schema, and its comments describe the schema as it is, not how it got there.Proof the schema is the same:
pg_dump --schema-onlyof the old 50 migrations and of the new file match exactly (tables, column order, constraint names, indexes, functions, triggers), except for the intended changes below.Intended schema changes (only old rows needed the old shape):
digest_keyisNOT NULLon authorization requests, codes and refresh tokens. NULL only meant a digest made before fingerprints were recorded, sokeys digest-usageloses itsunrecordedkey.invitations.idloses itsuuidv7()default, which served old rows and the previous release; auth always passes an ID.domain_events_readableis a validated constraint, no longerNOT VALID."format": 1) in the canonical event. The old untagged format 1 and format 2 are gone, along with the sealer's format switch.Removed code that only old data used:
importedevent (DomainEvent::Imported,ImportedAudit), itslegacyhistory entry and timeline wording, andActor::Unrecorded/HistoryActor::Unrecorded, which only imported rows had.SigningKeyChange::Imported, which only earlier releases wrote.scratch_schema/apply_migrationshelpers only they used.The recovery and redeemed-code triggers still run as their owner (
SECURITY DEFINER), so they hold even for a role not grantedaccount_recoveries, astests/recoveries.rschecks; only their comments changed. Docs and comments that cited migration numbers now name the triggers, functions or sections instead.Deploying: this needs a fresh database. An existing one has 50 applied migrations whose checksums no longer match.
Tests:
just db test(497 passed, thenprepare-check), thecommonanduitests,just docs, and workspace clippy. One caveat: the Rust 1.100 toolchain'smap_unwrap_orlint already fails across code this PR doesn't touch, so clippy ran with that lint allowed.Council review
Rounds: 2
Each reviewer rebuilt both schemas and compared the dumps on their own, and found no functional problems. Their findings were leftover migration numbers and out-of-date wording, all fixed, including three comment nits from round 2. Declined as beyond this PR: making the session device columns (
sessions.user_agent_family, IPs)NOT NULL, which would also change the settings UI's "unrecorded device" wording; and removingincidents.md's note about the oldsigning-keysecret, which lives in piqueld, not the database.Note
Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol, Claude Opus 5.5 and Claude Fable 5.2 (via T3 Code)