mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
23 lines
725 B
Go
23 lines
725 B
Go
package persistence
|
|
|
|
import (
|
|
"github.com/openziti/foundation/storage/ast"
|
|
"github.com/openziti/foundation/storage/boltz"
|
|
)
|
|
|
|
func (m *Migrations) fixServicePolicyTypes(step *boltz.MigrationStep) {
|
|
checker := boltz.MapFieldChecker{"type": struct{}{}}
|
|
for cursor := m.stores.ServicePolicy.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue); cursor.IsValid(); cursor.Next() {
|
|
id := cursor.Current()
|
|
policy, _ := m.stores.ServicePolicy.LoadOneById(step.Ctx.Tx(), string(id))
|
|
if policy != nil {
|
|
if policy.PolicyType == 5 { // old value for Bind
|
|
policy.PolicyType = PolicyTypeBind
|
|
} else {
|
|
policy.PolicyType = PolicyTypeDial
|
|
}
|
|
step.SetError(m.stores.ServicePolicy.Update(step.Ctx, policy, checker))
|
|
}
|
|
}
|
|
}
|