migrate/0.20: make the data migration deferrable to a task
1 files changed, 13 insertions(+), 5 deletions(-)

M tshistory/migrate.py
M tshistory/migrate.py +13 -5
@@ 164,7 164,7 @@ def migrate_series_versions(engine, name
     migrate_add_diffstart_diffend(engine, f'{namespace}.group', interactive)
 
 
-def migrate_add_diffstart_diffend(engine, namespace, interactive):
+def migrate_add_diffstart_diffend(engine, namespace, interactive, onlydata=False):
     import os
     import signal
     import sys

          
@@ 173,9 173,9 @@ def migrate_add_diffstart_diffend(engine
     from tshistory import util
     print(f'add columns `diffstart` and `diffend` to {namespace}.revision')
 
+    migdata = True
     if interactive:
-        if yesno('Defer data migration to a task ? [y/n] '):
-            return
+        migdata = not yesno('Defer data migration to the "migrate_diffs" task ? [y/n] ')
 
     def migrated(cn, tablename):
         sql = (

          
@@ 282,7 282,7 @@ def migrate_add_diffstart_diffend(engine
             name
             for name in allnames
             if allnames[name] is not None
-            and not migrated(cn, allnames[name])
+            and onlydata or not migrated(cn, allnames[name])
         ]
 
     print(f'{len(names)} series to migrate.')

          
@@ 299,8 299,11 @@ def migrate_add_diffstart_diffend(engine
                 cn.cache = {'series_tablename': {}}
                 tablename = tsh._series_to_tablename(cn, name)
                 print(f'{pid}: migrating `{name}`')
+                if not migdata:
+                    print(f'{pid}: no data migration')
                 addattributes(cn, tablename)
-                populatedata(pid, cn, name, tablename)
+                if migdata:
+                    populatedata(pid, cn, name, tablename)
                 finalizeattributes(cn, tablename)
 
     if cpus == 1:

          
@@ 325,6 328,11 @@ def migrate_add_diffstart_diffend(engine
                 print('kill', pid)
                 os.kill(pid, signal.SIGINT)
 
+    if migdata:
+        print(
+            'Do not forget to schedule the "migrate_diffs" task to complete the migration.'
+        )
+
 
 def migrate_metadata(engine, namespace, interactive):
     ns = namespace