settings,storage: add migration code

This commit is contained in:
Alex Shelkovnykov 2023-05-03 17:24:14 -03:00
parent c61f1fb30f
commit 7b839397bd
2 changed files with 74 additions and 19 deletions

View File

@ -18,13 +18,23 @@
%+ verb |
^- agent:gall
=<
|_ bol=bowl:gall
|_ =bowl:gall
+* this .
do ~(. +> bol)
def ~(. (default-agent this %|) bol)
io ~(. agentio bol)
do ~(. +> bowl)
def ~(. (default-agent this %|) bowl)
io ~(. agentio bowl)
::
++ on-init on-init:def
++ on-init
:: XX: deprecated; migration code
^- (quip card _this)
:_ this
:~ :* %pass
/migrate
%agent
[our dap]:bowl
%poke
noun+!>(%migrate)
== ==
::
++ on-save !>(state)
::
@ -42,23 +52,36 @@
++ on-poke
|= [mar=mark vas=vase]
^- (quip card _this)
?> (team:title our.bol src.bol)
?. ?=(%settings-event mar)
(on-poke:def mar vas)
=/ evt=event !<(event vas)
?> (team:title our.bowl src.bowl)
=^ cards state
?- -.evt
%put-bucket (put-bucket:do [desk key bucket]:evt)
%del-bucket (del-bucket:do [desk key]:evt)
%put-entry (put-entry:do [desk buc key val]:evt)
%del-entry (del-entry:do [desk buc key]:evt)
?+ mar (on-poke:def mar vas)
%settings-event
=/ evt=event !<(event vas)
?- -.evt
%put-bucket (put-bucket:do [desk key bucket]:evt)
%del-bucket (del-bucket:do [desk key]:evt)
%put-entry (put-entry:do [desk buc key val]:evt)
%del-entry (del-entry:do [desk buc key]:evt)
==
::
:: XX: deprecated; migration code
%noun
?> ?=(%migrate !<(%migrate vas))
=/ bas /(scot %p our.bowl)/settings-store/(scot %da now.bowl)
:- ~
?. .^(? %gu bas)
state
=/ ful .^(data %gx (weld bas /all/noun))
?+ -.ful (on-poke:def mar vas)
%all state(settings +.ful)
==
==
[cards this]
::
++ on-watch
|= pax=path
^- (quip card _this)
?> (team:title our.bol src.bol)
?> (team:title our.bowl src.bowl)
?+ pax (on-watch:def pax)
[%all ~]
[~ this]

View File

@ -27,8 +27,18 @@
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-init
:: XX: deprecated; migration code
^- (quip card _this)
:_ this
:~ :* %pass
/migrate
%agent
[our dap]:bowl
%poke
noun+!>(%migrate)
== ==
++ on-save !>(state)
++ on-load
|= =vase
=/ old !<(versioned-state vase)
@ -60,8 +70,30 @@
|^
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
%storage-action (poke-action !<(action vase))
?+ mark (on-poke:def mark vase)
%storage-action
(poke-action !<(action vase))
::
:: XX: deprecated; migration code
%noun
?> ?=(%migrate !<(%migrate vase))
=/ bas /(scot %p our.bowl)/s3-store/(scot %da now.bowl)
:- ~
?. .^(? %gu bas)
state
=:
credentials
=/ ful .^(update %gx (weld bas /credentials/noun))
?+ -.ful (on-poke:def mark vase)
%credentials +.ful
==
::
configuration
=/ ful .^(update %gx (weld bas /configuration/noun))
?+ -.ful (on-poke:def mark vase)
%configuration +.ful
== ==
state
==
[cards this]
::