metadata-store: migrate indices properly
+$ state-2 [%2 base-state-0]
+$ state-3 [%3 base-state-1]
+$ state-4 [%4 base-state-1]
++$ state-5 [%5 base-state-1]
+$ versioned-state
$% state-0
state-1
state-2
state-3
state-4
+ state-5
==
--
::
-=| state-4
+=| state-5
=* state -
%+ verb |
%- agent:dbug
=/ old !<(versioned-state vase)
=| cards=(list card)
|^
- ?: ?=(%4 -.old)
+ ?: ?=(%5 -.old)
[cards this(state old)]
- ?: ?=(%3 -.old)
+ ?: ?=(%4 -.old)
%_ $
- -.old %4
+ -.old %5
::
- resource-indices.old
- (rebuild-resource-indices associations.old)
+ group-indices.old
+ %- ~(gas ju *(jug group-path md-resource))
+ ~(tap in ~(key by associations.old))
::
app-indices.old
- (rebuild-app-indices associations.old)
+ %- ~(gas ju *(jug app-name [group-path app-path]))
+ %+ turn ~(tap in ~(key by associations.old))
+ |= [g=group-path r=md-resource]
+ ^- [app-name [group-path app-path]]
+ [app-name.r [g app-path.r]]
::
- group-indices.old
- (rebuild-group-indices associations.old)
+ resource-indices.old
+ %- ~(gas ju *(jug md-resource group-path))
+ %+ turn ~(tap in ~(key by associations.old))
+ |= [g=group-path r=md-resource]
+ ^- [md-resource group-path]
+ [r g]
==
+ ?: ?=(%3 -.old)
+ $(old [%4 +.old])
?: ?=(%2 -.old)
=/ new-state=state-3
%* . *state-3
==
$(old new-state-1)
::
- ++ rebuild-app-indices
- =| app-indices=(jug app-name [group-path app-path])
- |= =^associations
- ^- (jug app-name [group-path app-path])
- ?~ associations app-indices
- =. app-indices
- %+ ~(put ju app-indices) app-name.p.n.associations
- [-.p.n.associations app-path.p.n.associations]
- %- ~(uni by $(associations l.associations))
- $(associations r.associations)
- ::
- ++ rebuild-group-indices
- =| group-indices=(jug group-path md-resource)
- |= =^associations
- ^- (jug group-path md-resource)
- ?~ associations group-indices
- =. group-indices
- %+ ~(put ju group-indices)
- -.p.n.associations
- +.p.n.associations
- %- ~(uni by $(associations l.associations))
- $(associations r.associations)
- ::
- ++ rebuild-resource-indices
- =| resource-indices=(jug md-resource group-path)
- |= =^associations
- ^- (jug md-resource group-path)
- ?~ associations resource-indices
- =. resource-indices
- %+ ~(put ju resource-indices)
- +.p.n.associations
- -.p.n.associations
- %- ~(uni by $(associations l.associations))
- $(associations r.associations)
- ::
++ poke-md-hook
|= act=metadata-hook-action
^- card
