[#102] container: Migrate container listing storage
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
98c5fd25c3
commit
2402768eae
1 changed files with 18 additions and 0 deletions
|
@ -66,6 +66,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
ctx := storage.GetContext()
|
||||
|
||||
if isUpdate {
|
||||
migrateContainerLists(ctx) // from v0.9.1 to v0.9.2
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -99,6 +100,23 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
runtime.Log("container contract initialized")
|
||||
}
|
||||
|
||||
func migrateContainerLists(ctx storage.Context) {
|
||||
const ownersKey = "ownersList"
|
||||
|
||||
containers := getAllContainers(ctx)
|
||||
for i := range containers {
|
||||
containerID := containers[i]
|
||||
ownerID := getOwnerByID(ctx, containerID)
|
||||
|
||||
containerListKey := append(ownerID, containerID...)
|
||||
storage.Put(ctx, containerListKey, containerID)
|
||||
|
||||
storage.Delete(ctx, ownerID)
|
||||
}
|
||||
|
||||
storage.Delete(ctx, ownersKey)
|
||||
}
|
||||
|
||||
func Migrate(script []byte, manifest []byte, data interface{}) bool {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
|
||||
|
|
Loading…
Reference in a new issue