# HG changeset patch # User Adrien Di Mascio # Date 1253692441 -7200 # Node ID 405f393bcac00f3ed90167db07f6c12a99d1ba34 # Parent 51a25bdd7bdcf59cd03bb73de3ba2562d47bd45d [migration] fix bootstrap migration of 3.5 : need to support old-style and new-style hooks to migrate from 3.4 to 3.6 diff -r 51a25bdd7bdc -r 405f393bcac0 misc/migration/bootstrapmigration_repository.py --- a/misc/migration/bootstrapmigration_repository.py Wed Sep 23 09:52:52 2009 +0200 +++ b/misc/migration/bootstrapmigration_repository.py Wed Sep 23 09:54:01 2009 +0200 @@ -35,14 +35,22 @@ # 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') + from cubicweb.hooks import syncschema + repo.vreg.unregister(syncschema.AfterDelRelationTypeHook) + try: + drop_relation_definition('State', 'allowed_transition', 'Transition') + finally: + repo.vreg.register(syncschema.AfterDelRelationTypeHook) + except ImportError: # syncschema is in CW >= 3.6 only + 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',