Replace GORM + AutoMigrate with golang-migrate + sqlc#1561
Draft
iplay88keys wants to merge 11 commits intomainfrom
Draft
Replace GORM + AutoMigrate with golang-migrate + sqlc#1561iplay88keys wants to merge 11 commits intomainfrom
iplay88keys wants to merge 11 commits intomainfrom
Conversation
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>
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
commented
Mar 30, 2026
…ranch 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>
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.
Description
Warning
Upgrading from a version earlier than v0.8.0 is not supported. You must upgrade to v0.8.0+ before upgrading to this version.
GORM's
AutoMigrateis additive-only, leaves no migration history, and has no rollback path. This PR replaces it with versioned SQL migrations (golang-migrate) and compile-time type-safe query generation (sqlc).Migration is now handled by an init container rather than the controller on startup.
A new CI check fails if any existing migration file is modified. Migrations are immutable once merged.
What this changes for operators
CREATE TABLE IF NOT EXISTS, so all data is preservedTesting
An integration test (
TestUpgradeFromGORM) applies the pre-migration schema, seeds realistic data, runs the new migrations, and verifies everything is readable and writable afterward.Manual upgrade testing was also performed against a live Kind cluster:
mainwith all default agents running against PostgreSQLcurrency-converter-agent(LangGraph) andpoem-flow-agent(CrewAI Flow) samples to populatelg_checkpoint,lg_checkpoint_write, andcrewai_flow_statemigrateinit container ran successfully (core migrations applied,vector migrations applied)Schema validation
To validate the migration produces a correct schema in both upgrade and fresh-install paths,
pg_dump --schema-onlywas captured after each scenario and compared:schema_migrations,vector_schema_migrations, andmemory.id DEFAULT gen_random_uuid()were addedmake helm-installfrom scratch. The resulting schema was functionally identical to the upgraded schema (column ordering within tables differs only where GORM's struct-field ordering diverged from the migration file, which has no runtime impact)