-
Notifications
You must be signed in to change notification settings - Fork 159
/
migration_v17.go
31 lines (26 loc) · 1.04 KB
/
migration_v17.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package db
import (
"fmt"
"github.com/openziti/storage/ast"
"github.com/openziti/storage/boltz"
)
// Removes all ApiSession and Session from the edge. Necessary from 0.18 -> 0.19
// as the id format changed and API Session sync'ing depends on monotonic ids.
func (m *Migrations) removeAllSessions(step *boltz.MigrationStep) {
for cursor := m.stores.Session.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue); cursor.IsValid(); cursor.Next() {
current := cursor.Current()
currentSessionId := string(current)
if err := m.stores.Session.DeleteById(step.Ctx, currentSessionId); err != nil {
step.SetError(fmt.Errorf("error cleaing up sessions for migration: %v", err))
return
}
}
for cursor := m.stores.ApiSession.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue); cursor.IsValid(); cursor.Next() {
current := cursor.Current()
currentApiSessionId := string(current)
if err := m.stores.ApiSession.DeleteById(step.Ctx, currentApiSessionId); err != nil {
step.SetError(fmt.Errorf("error cleaing up api sessions for migration: %v", err))
return
}
}
}