Add query-contraction check against the previous release#2085
Conversation
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
…contraction-check Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
There was a problem hiding this comment.
Pull request overview
Adds a static, offline CI gate that verifies backward compatibility of database schema migrations by compiling a previous release’s sqlc queries against the current schema derived from migrations. This supports safer rollbacks and rolling deploys by catching schema contractions (drops/renames/type changes) that would break older binaries.
Changes:
- Add
scripts/check-query-contraction.shto compile prior-releasesqlcqueries against the current migration-derived schema. - Add
scripts/prev-stable-version.shto resolve the rollback-floor target (latest patch on the previous stable release line). - Wire the check into CI and
go/Makefile, and document the relationship with the existingsqlc generateschema gate.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/prev-stable-version.sh | Determines the latest patch tag on the stable line below the currently-built line. |
| scripts/check-query-contraction.sh | Stages current migrations + previous-release queries and runs sqlc compile as a compatibility gate. |
| go/Makefile | Adds a check-query-contraction target for local/CI invocation. |
| go/core/internal/database/sqlc.yaml | Documents how schema-from-migrations makes sqlc generate a forward-compatibility safety gate and points to the new backward check. |
| .github/workflows/ci.yaml | Adds a dedicated Query Contraction Check job and switches Go setup to go-version-file in multiple jobs. |
| .claude/skills/kagent-dev/references/database-migrations.md | Updates the migrations guide to describe/enumerate the new query-level compatibility check. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
EItanya
left a comment
There was a problem hiding this comment.
Just the one nit about script placement since it's only used there
| # fetched. TARGET_VERSIONS (space-separated) overrides the auto-derived release(s). | ||
| .PHONY: check-query-contraction | ||
| check-query-contraction: sqlc ## Verify the previous release's queries still type-check against the current schema | ||
| SQLC=$(SQLC) ../scripts/check-query-contraction.sh |
There was a problem hiding this comment.
nit: should we just put this script in go/scripts?
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.26" | ||
| go-version-file: go/go.mod |
There was a problem hiding this comment.
Can this be used by both this PR and the upgrade tests?
Description
Adds a static check that a migration on this branch doesn't break the queries a prior release still runs — the backward-compatibility property that makes a one-step rollback (and a rolling deploy) safe.
It compiles a prior release's sqlc queries against the current schema (derived from the migration files) and fails if a migration dropped, renamed, or retyped a column or table an older query still references. Runs in normal CI on every PR — no database, no cluster.
Targets
Checks two prior versions (deduplicated when they coincide):
release/vX.Y.xtip) — the rollback-window floor.Running
Override the targets with
TARGET_VERSIONS(space-separated, no leadingv).Notes
sqlc generategate (schema derived from migrations) as the forward-direction equivalent for current-release queries.