fix: validate explicit migrations and preserve large business ids

This commit is contained in:
Yvan
2026-11-06 07:00:05 +08:00
parent f6f2a4745e
commit 0f0ec2e6d7
53 changed files with 2653 additions and 1445 deletions
+8
View File
@@ -145,6 +145,9 @@ func (d *Data) reloadConfig(ctx context.Context) error {
var undo rollback
defer undo.run()
databaseReady := databaseConnectionConfigured(next.Data.Database)
if !databaseReady && next.Admin.System != nil && next.Admin.System.DisableAutoMigrate {
return fmt.Errorf("automatic migration is disabled; an existing migrated database is required")
}
var candidateDB *gorm.DB
if databaseReady {
candidateDB, err = openDatabase(next.Data.Database, false, "", d.logger())
@@ -170,6 +173,11 @@ func (d *Data) reloadConfig(ctx context.Context) error {
return fmt.Errorf("reload database migrations: %w", err)
}
}
if databaseReady && next.Admin.System != nil && next.Admin.System.DisableAutoMigrate {
if err = checkMigratedSchema(candidateDB.WithContext(ctx), d.catalog); err != nil {
return fmt.Errorf("reload database schema: %w", err)
}
}
storageConfig, err := dataintegration.ResolveStorageConfig(candidateDB.WithContext(ctx), next.Admin.Storage)
if err != nil {
return fmt.Errorf("reload storage configuration: %w", err)