fix(models): isolate versioned migration sessions

This commit is contained in:
2026-07-22 14:45:41 +08:00
parent 78d4845688
commit 217f82c57c
2 changed files with 12 additions and 5 deletions

View File

@@ -35,7 +35,10 @@ func TestAutoMigrateUpgradesLegacyProjectsAndTagsWithoutLosingAssociations(t *te
require.NoError(t, database.Exec(statement).Error)
}
require.NoError(t, AutoMigrate(database))
// PostgreSQL migrations run through database.Connection, whose callback DB can
// carry an initialized Gorm statement. Exercise that mode so model state from
// the migration-version lookup cannot leak into the data-repair transaction.
require.NoError(t, AutoMigrate(database.Session(&gorm.Session{Initialized: true})))
var projects []SenlinAgentProject
require.NoError(t, database.Order("id asc").Find(&projects).Error)