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