[migrations/pdb] add to every failing migration operation a "p(db)" option
authorLaurent Peuch <cortex@worlddomination.be>
Thu, 23 May 2019 00:33:31 +0200
changeset 12752 3cf37ec616ad
parent 12751 30b205676182
child 12753 38d24fb2ae48
[migrations/pdb] add to every failing migration operation a "p(db)" option Instead, the migration command will just crash without offering the possibility of the user to debug or continue the migration. Closes #17219772
cubicweb/migration.py
--- a/cubicweb/migration.py	Wed May 29 20:29:07 2019 +0200
+++ b/cubicweb/migration.py	Thu May 23 00:33:31 2019 +0200
@@ -23,6 +23,7 @@
 import logging
 import tempfile
 import itertools
+import traceback
 from os.path import exists, join, basename, splitext
 from itertools import chain
 
@@ -133,8 +134,14 @@
             # search self.__class__ to avoid infinite recursion
             if hasattr(self.__class__, cmd):
                 meth = getattr(self, cmd)
-                return lambda *args, **kwargs: self.interact(args, kwargs,
-                                                             meth=meth)
+                try:
+                    return lambda *args, **kwargs: self.interact(args, kwargs,
+                                                                 meth=meth)
+                except:
+                    _, ex, traceback_ = sys.exc_info()
+                    traceback.print_exc()
+                    if self.confirm('abort?', pdb=True, traceback=traceback_):
+                        raise
             raise
         raise AttributeError(name)