Files
backrest/internal/config/migrations/migrations.go
2024-05-19 15:52:16 -07:00

27 lines
568 B
Go

package migrations
import (
v1 "github.com/garethgeorge/backrest/gen/go/v1"
"go.uber.org/zap"
)
var migrations = []func(*v1.Config){
migration001PrunePolicy,
migration002Schedules,
}
var CurrentVersion = int32(len(migrations))
func ApplyMigrations(config *v1.Config) error {
startMigration := int(config.Version - 1)
if startMigration < 0 {
startMigration = 0
}
for idx := startMigration; idx < len(migrations); idx += 1 {
zap.S().Infof("applying config migration %d", idx+1)
migrations[idx](config)
}
config.Version = CurrentVersion
return nil
}