Call migrations per version

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2023-09-28 15:24:26 -07:00
parent 62f273d508
commit 46645b393b
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -202,10 +202,13 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
required[r] = struct{}{} required[r] = struct{}{}
} }
if config.Version < srvconfig.CurrentConfigVersion { // Run migration for each configuration version
// Run each plugin migration for each version to ensure that migration logic is simple and
// focused on upgrading from one version at a time.
for v := config.Version; v < srvconfig.CurrentConfigVersion; v++ {
for _, p := range plugins { for _, p := range plugins {
if p.ConfigMigration != nil { if p.ConfigMigration != nil {
if err := p.ConfigMigration(ctx, config.Version, config.Plugins); err != nil { if err := p.ConfigMigration(ctx, v, config.Plugins); err != nil {
return nil, err return nil, err
} }
} }