@@ -25,26 +25,29 @@ def migrate(version: 0, local: MyPyClass, ton: MyTonCore):
25
25
if version < 1 :
26
26
local .add_log (f'Running migration { version } -> 1' , 'info' )
27
27
migrate_to_version_1 (local , ton )
28
+ return 1
28
29
29
30
30
31
def run_migrations (local : Optional [MyPyClass ]= None , ton : Optional [MyTonCore ]= None ):
31
- if local is None :
32
- local = MyPyClass ('mytonctrl.py' )
33
- if ton is None :
34
- ton = MyTonCore (MyPyClass ('mytoncore.py' ))
35
-
36
- # migrations
37
- local .add_log ('Running MyTonCtrl migrations' , 'info' )
38
-
39
- workdir = local .buffer .my_work_dir
40
- local .add_log (f"Workdir: { workdir } " , 'info' )
41
-
42
- version = 0
43
- version_file_path = os .path .join (workdir , 'VERSION' )
44
- if os .path .exists (version_file_path ):
45
- with open (version_file_path , 'r' ) as f :
46
- version = int (f .read ())
47
- local .add_log (f'Current version: { version } ' , 'info' )
48
-
49
- migrate (version , local , ton )
50
- #end define
32
+ if local is None :
33
+ local = MyPyClass ('mytonctrl.py' )
34
+ if ton is None :
35
+ ton = MyTonCore (MyPyClass ('mytoncore.py' ))
36
+
37
+ # migrations
38
+ local .add_log ('Running MyTonCtrl migrations' , 'info' )
39
+
40
+ workdir = local .buffer .my_work_dir
41
+ local .add_log (f"Workdir: { workdir } " , 'info' )
42
+
43
+ version = 0
44
+ version_file_path = os .path .join (workdir , 'VERSION' )
45
+ if os .path .exists (version_file_path ):
46
+ with open (version_file_path , 'r' ) as f :
47
+ version = int (f .read ())
48
+ local .add_log (f'Current version: { version } ' , 'info' )
49
+
50
+ new_version = migrate (version , local , ton )
51
+ with open (version_file_path , 'w' ) as f :
52
+ f .write (f'{ new_version } ' )
53
+ #end define
0 commit comments