fix database config parsing

This commit is contained in:
c9s 2024-01-26 16:39:05 +08:00
parent 2742b192b6
commit 93bddfdccd
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 5 additions and 5 deletions

View File

@ -327,10 +327,10 @@ type ServiceConfig struct {
} }
type DatabaseConfig struct { type DatabaseConfig struct {
Driver string `json:"driver"` Driver string `json:"driver" yaml:"driver"`
DSN string `json:"dsn"` DSN string `json:"dsn" yaml:"dsn"`
ExtraMigrationPackages []string `json:"extraMigrationPackages"` ExtraMigrationPackages []string `json:"extraMigrationPackages" yaml:"extraMigrationPackages"`
} }
type EnvironmentConfig struct { type EnvironmentConfig struct {

View File

@ -198,13 +198,13 @@ func (environ *Environment) ConfigureDatabase(ctx context.Context, config *Confi
func (environ *Environment) ConfigureDatabaseDriver(ctx context.Context, driver string, dsn string, extraPkgNames ...string) error { func (environ *Environment) ConfigureDatabaseDriver(ctx context.Context, driver string, dsn string, extraPkgNames ...string) error {
environ.DatabaseService = service.NewDatabaseService(driver, dsn) environ.DatabaseService = service.NewDatabaseService(driver, dsn)
environ.DatabaseService.AddMigrationPackages(extraPkgNames...)
err := environ.DatabaseService.Connect() err := environ.DatabaseService.Connect()
if err != nil { if err != nil {
return err return err
} }
environ.DatabaseService.AddMigrationPackages(extraPkgNames...)
if err := environ.DatabaseService.Upgrade(ctx); err != nil { if err := environ.DatabaseService.Upgrade(ctx); err != nil {
return err return err
} }