misc/migration/bootstrapmigration_repository.py
changeset 3230 1d25e928c299
parent 2968 0e3460341023
parent 3218 2a4bbe3fa4f3
child 3369 7b88d12b4ee2
--- a/misc/migration/bootstrapmigration_repository.py	Mon Sep 14 11:25:56 2009 +0200
+++ b/misc/migration/bootstrapmigration_repository.py	Tue Sep 15 15:01:41 2009 +0200
@@ -32,7 +32,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',