[migration] warn if 3.5 workflow migration is going to fail stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Sun, 01 Nov 2009 21:40:03 +0100
branchstable
changeset 3788 3d5abcd7c852
parent 3787 82bb2c7f083b
child 3789 fb22b55f80f8
[migration] warn if 3.5 workflow migration is going to fail
misc/migration/bootstrapmigration_repository.py
--- a/misc/migration/bootstrapmigration_repository.py	Wed Oct 28 20:09:59 2009 +0100
+++ b/misc/migration/bootstrapmigration_repository.py	Sun Nov 01 21:40:03 2009 +0100
@@ -31,6 +31,17 @@
     session.set_shared_data('do-not-insert-cwuri', False)
 
 if applcubicwebversion < (3, 5, 0) and cubicwebversion >= (3, 5, 0):
+    # check that migration is not doomed
+    rset = rql('Any X,Y WHERE X transition_of E, Y transition_of E, '
+               'X name N, Y name N, NOT X identity Y',
+               ask_confirm=False)
+    if rset:
+        from logilab.common.shellutils import ASK
+        if not ASK.confirm('Migration will fail because of transitions with the same name. '
+                           'Continue anyway ?'):
+            import sys
+            sys.exit(1)
+    # proceed with migration
     add_entity_type('Workflow')
     add_entity_type('BaseTransition')
     add_entity_type('WorkflowTransition')