misc/migration/bootstrapmigration_repository.py
branch3.5
changeset 3218 2a4bbe3fa4f3
parent 2965 75ad5cb00b88
child 3230 1d25e928c299
child 3305 abae9045d2e4
--- 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',