Call migrations per version
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
parent
62f273d508
commit
46645b393b
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user