[migration] fix migration of old cw instances which do not have yet the CWUniqueTogetherConstraint entity type stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 Jan 2011 08:23:27 +0100
branchstable
changeset 6852 970d1aab42a1
parent 6850 2b9e58174327
child 6853 584679872fd7
[migration] fix migration of old cw instances which do not have yet the CWUniqueTogetherConstraint entity type
misc/migration/3.10.7_Any.py
--- a/misc/migration/3.10.7_Any.py	Wed Jan 19 18:01:28 2011 +0100
+++ b/misc/migration/3.10.7_Any.py	Thu Jan 20 08:23:27 2011 +0100
@@ -1,8 +1,9 @@
-add_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWRType')
-rql('SET C relations RT WHERE C relations RDEF, RDEF relation_type RT')
-commit()
-drop_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWAttribute')
-drop_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWRelation')
+if not ('CWUniqueTogetherConstraint', 'CWRType') in schema['relations'].rdefs:
+    add_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWRType')
+    rql('SET C relations RT WHERE C relations RDEF, RDEF relation_type RT')
+    commit()
+    drop_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWAttribute')
+    drop_relation_definition('CWUniqueTogetherConstraint', 'relations', 'CWRelation')
 
 add_attribute('TrInfo', 'tr_count')
 sync_schema_props_perms('TrInfo')