fix: validate explicit migrations and preserve large business ids
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user