Switch to using goose for migrations - #2667
Open
iplay88keys wants to merge 10 commits into
Open
Conversation
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
iplay88keys
force-pushed
the
iplay88keys/goose-migrations
branch
from
September 2, 2026 23:50
6b00123 to
a7aeb46
Compare
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
…rations 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>
iplay88keys
marked this pull request as ready for review
September 3, 2026 16:48
…rations Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io> # Conflicts: # go/core/cmd/controller-v2/main.go
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
…rations Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io> # Conflicts: # go/core/pkg/migrations/core/000001_initial.down.sql # go/core/pkg/migrations/core/000001_initial.up.sql # go/core/pkg/migrations/core/000002_not_null_defaults.down.sql # go/core/pkg/migrations/core/000002_not_null_defaults.up.sql
EItanya
reviewed
Sep 3, 2026
| if err != nil { | ||
| return err | ||
| } | ||
| vectorEnabled := envBool("DATABASE_VECTOR_ENABLED") |
Contributor
There was a problem hiding this comment.
Can we define these env vars as consts somewhere so they're properly documented, we used to have a env var package somewhere
Comment on lines
+55
to
+56
| assertAgentInstanceInteraction(t, fixture) | ||
| assertAgentInstanceInteraction(t, fixture) |
Contributor
There was a problem hiding this comment.
Why this change, you're explicitly running it twice?
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.
Warning
This is an intentional clean slate for 1.0:
Summary
Replace golang-migrate with Goose and establish a clean PostgreSQL migration baseline for Kagent 1.0.
Why
golang-migrate records a dirty version separately from the migration transaction.
A failure between the schema commit and the final version update can leave a committed schema marked dirty, requiring an operator to inspect the database and force a version.
Goose records the schema change and migration version in the same PostgreSQL transaction.
A failed migration rolls both back, and startup can safely retry it.
Substrate PR #1196 made the same change; this review thread describes the failure mode.
What changed
Goose runner and migration files
github.com/golang-migrate/migratewithgithub.com/pressly/goose/v3.core/000001_initial.sql.vector/000001_initial.sql.-- +goose Upand-- +goose Downsections for Kagent migrations.-- +goose NO TRANSACTIONso schema changes and migration records remain atomic.Each source still commits independently.
If a later source fails, previously completed sources remain committed and the next startup resumes from their recorded versions.
Migration immutability CI permits deletion of the legacy split files for this cutover, then protects merged Goose migrations from modification, rename, or deletion.
Database CLI
The migration CLI now operates on Goose providers:
upapplies all pending sources.down Nandgoto Vmove one selected source within its embedded Goose sequence.statusandversionreport Goose state.forceand the dirty-state output are removed.Destructive commands reject a database version newer than the CLI's embedded migrations.
The CLI continues to resolve vector-source enablement from its environment, the controller ConfigMap, or its standalone fallback.
Controller startup and Helm settings
Controller startup now honors the existing Helm settings:
DATABASE_VECTOR_ENABLED=trueincludes the vector migration source and registers pgvector types on database connections.SKIP_MIGRATIONS=trueperforms read-only migration verification instead of applying migrations.This matches the 0.10.x behavior of
database.postgres.vectorEnabledanddatabase.postgres.skipMigrations.Upgrade tests and CI
The upgrade suites now understand Goose state and use the API v2 AgentInstance gRPC interaction test.
They cover data survival, previous-release behavior after target migrations, clean-install schema equivalence, application rollback, schema rollback, and the old-controller/new-schema window during a rolling deployment.
Previous-release tests run from a temporary worktree at the matching tag.
The previous chart installation also reads its bundled-PostgreSQL overrides from that tag's Makefile so the baseline matches the release as shipped.
Both normal and rolling jobs include these matrix legs:
adjacenttests patch and prerelease upgrades on release branches.prev-stabletests the previous release line for minor-version compatibility.The shared setup skips 0.10.x because it predates Goose.
There will be no 0.11.x release.
Once a 1.0 prerelease or final artifact is published,
prev-stableautomatically begins testing 1.0 against the next development line.Verification
origin/mainand the new Goose baselines to separate fresh databases; their schema-onlypg_dumpoutput matched exactly after excluding the intentionally different migration-ledger tables.go test ./core/pkg/migrations ./core/pkg/cli/db/migrate ./core/test/upgrade ./core/internal/databasego vet ./core/pkg/migrations ./core/pkg/cli/db/migrate ./core/test/upgrade ./core/internal/databasemake lintmake sqlc-generatego test -short ./core/pkg/migrations ./core/pkg/cli/db/migrate ./core/cli/internal/commands/dbgo test -race ./core/pkg/migrations ./core/pkg/cli/db/migratego test ./core/pkg/app ./core/cmd/controller-v2 ./core/pkg/migrations ./core/internal/databasebash scripts/version-resolution_test.shgit diff --check