[3.5 migration] avoid removing defined transitions... 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 14 Sep 2009 18:59:17 +0200
branch3.5
changeset 3218 2a4bbe3fa4f3
parent 3217 1980e9386161
child 3219 be8cfc00ae04
[3.5 migration] avoid removing defined transitions...
misc/migration/bootstrapmigration_repository.py
--- a/misc/migration/bootstrapmigration_repository.py	Mon Sep 14 18:58:51 2009 +0200
+++ b/misc/migration/bootstrapmigration_repository.py	Mon Sep 14 18:59:17 2009 +0200
@@ -35,7 +35,17 @@
     add_entity_type('BaseTransition')
     add_entity_type('WorkflowTransition')
     add_entity_type('SubWorkflowExitPoint')
-    drop_relation_definition('State', 'allowed_transition', 'Transition') # should be infered
+    # drop explicit 'State allowed_transition Transition' since it should be
+    # infered due to yams inheritance.  However we've to disable the schema
+    # sync hook first to avoid to destroy existing data...
+    from cubicweb.server.schemahooks import after_del_relation_type
+    repo.hm.unregister_hook(after_del_relation_type,
+                            'after_delete_relation', 'relation_type')
+    try:
+        drop_relation_definition('State', 'allowed_transition', 'Transition')
+    finally:
+        repo.hm.register_hook(after_del_relation_type,
+                              'after_delete_relation', 'relation_type')
     schema.rebuild_infered_relations() # need to be explicitly called once everything is in place
 
     for et in rql('DISTINCT Any ET,ETN WHERE S state_of ET, ET name ETN',