Files
zt/controller/db/migration_v24.go
zeekay 873220f90b rebrand: openziti → hanzozt (Hanzo Zero Trust)
Global rebrand of all OpenZiti references to Hanzo ZT:
- Go module paths: github.com/openziti/* → github.com/hanzozt/*
- Docker images: openziti/* → hanzozt/*
- Java packages: org.openziti.* → org.hanzozt.*
- Brand: OpenZiti → Hanzo ZT
- URLs: openziti.io → hanzozt.dev
2026-02-18 16:13:53 -08:00

46 lines
1.1 KiB
Go

package db
import (
"fmt"
"github.com/hanzozt/storage/ast"
"github.com/hanzozt/storage/boltz"
)
func (m *Migrations) addIdentityIdToSessions(step *boltz.MigrationStep) {
cursor := m.stores.Session.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue)
fieldChecker := boltz.MapFieldChecker{
FieldSessionIdentity: struct{}{},
}
for cursor.IsValid() {
sessionId := string(cursor.Current())
session, err := m.stores.Session.LoadById(step.Ctx.Tx(), sessionId)
if err != nil {
step.SetError(fmt.Errorf("could no load session by id [%s]: %v", sessionId, err))
return
}
if session == nil {
step.SetError(fmt.Errorf("session [%s] load did not error but session is null", sessionId))
return
}
if session.IdentityId == "" {
if apiSession, err := m.stores.ApiSession.LoadById(step.Ctx.Tx(), session.ApiSessionId); err == nil {
if apiSession != nil {
session.IdentityId = apiSession.IdentityId
if err = m.stores.Session.Update(step.Ctx, session, fieldChecker); err != nil {
step.SetError(fmt.Errorf("could not update session [%s]: %v", session.Id, err))
return
}
}
}
}
cursor.Next()
}
}