Repository navigation
feat(server): migrate the control store with numbered migrations - #1563
Merged
Merged
Conversation
The control store records a schema version next to its checksum. A server creates a new store at the current version and upgrades an older one by applying the numbered migrations after it, in one transaction under the store lock. On SQLite, the transaction runs with foreign keys off so a migration can rebuild a referenced table, then checks them before committing. Stores from releases before versioning that match the version 1 baseline are upgraded in place. The server refuses a store written by a newer release, a store older than the baseline, and a store at the current version whose schema differs, each with the fix. `sqb server migrate` applies the pending migrations and exits; `--dry-run` lists them without changing the store. Contract tests on SQLite and PostgreSQL check that the baseline plus every migration matches a new store, that a populated store keeps its rows, that a migration can rebuild sqb_runs, the refusals, and the dry run.
`sqb server migrate --dry-run` opened the store to plan the migration, and opening a SQLite store creates its file and parent directories. A dry run on a missing file now reports that there is no store and that a migration would create one, without creating anything.
kvlonge
disabled auto-merge
November 17, 2026 23:17
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 18, 2026
Windows checkouts turn schema.sql and indexes.sql into CRLF, and the binaries embed them as checked out. A Windows build therefore recorded a different checksum than a Linux or macOS build for the same schema: it refused the baseline store from a Windows release as older than version 1, and Windows and Linux servers sharing a PostgreSQL store would disagree about whether its schema matches. The checksum is now taken over LF text, and the baseline accepts both checksums released stores recorded: from LF and from CRLF SQL. The SQL files are also checked out with LF everywhere.
kvlonge
disabled auto-merge
November 18, 2026 01:54
kvlonge
enabled auto-merge
November 18, 2026 01:55
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.
Why
The control store had no upgrade path. A server refused any store whose schema checksum differed, so every
schema.sqlchange forced users to recreate their store, losing people, roles, tokens, triggers and run history.Changes
sqb_schema_versionrecords a version. A new store is created fromschema.sqland stamped with the current version. Older stores apply the numbered migrations after their version in one transaction under the store lock. On SQLite that transaction runs with foreign keys off, so a migration can rebuild a referenced table, and checks them before committing.indexes.sqland ignores line endings, so Windows builds agree with the others.sqb server migrateapplies pending migrations and exits;--dry-runlists them and changes nothing.store_migrations/, one per version with SQLite and PostgreSQL SQL.Verification
sqb_runsrebuild, refusals, a migration that breaks a reference, and the dry run.schema.sqledit without a migration; the rebuild with SQLite foreign keys on.sqb server migrate [--dry-run], including a dry run without a SQLite store, which must create nothing (failed before the guard).make check-cipasses on this head.