优化结构
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
datapayment "kra/internal/data/payment"
|
||||
datasystem "kra/internal/data/repository"
|
||||
"kra/pkg/database/migration"
|
||||
"kra/pkg/module"
|
||||
|
||||
@@ -10,26 +8,14 @@ import (
|
||||
)
|
||||
|
||||
func InfrastructureMigrations() []migration.Step {
|
||||
return []migration.Step{
|
||||
{
|
||||
ID: "202608200001_data_infrastructure",
|
||||
Migrate: func(db *gorm.DB) error {
|
||||
return migration.CreateMissingTables(db, &integrationConfigPO{})
|
||||
},
|
||||
},
|
||||
{ID: "202608210001_communication_integration_defaults", Migrate: ensureCommunicationIntegrationConfigs},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// migrateAll is the single data-layer migration entry point. Module-specific
|
||||
// schema work stays with the module that owns its persistent objects.
|
||||
func migrateAll(db *gorm.DB, catalogs ...module.Catalog) error {
|
||||
steps := InfrastructureMigrations()
|
||||
if len(catalogs) > 0 && len(catalogs[0].MigrationSteps()) > 0 {
|
||||
steps = append(steps, catalogs[0].MigrationSteps()...)
|
||||
} else {
|
||||
steps = append(steps, datasystem.Migrations()...)
|
||||
steps = append(steps, datapayment.Migrations()...)
|
||||
}
|
||||
// migrateAll is the single data-layer migration entry point. Every module
|
||||
// must register its migrations through the application catalog; there is no
|
||||
// hidden system/payment fallback that could silently omit a new module.
|
||||
func migrateAll(db *gorm.DB, catalog module.Catalog) error {
|
||||
steps := append([]migration.Step{}, InfrastructureMigrations()...)
|
||||
steps = append(steps, catalog.MigrationSteps()...)
|
||||
return migration.Run(db, steps)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user