# HG changeset patch # User Julien Cristau # Date 1389806425 -3600 # Node ID ce072c9aa5732ca608b94c64cb6859237f7d1d24 # Parent 2f684e5381743fc80de3a88e7ad3f13be7688e03 [migration/3.18] Explicitly delete constraint on defaultval Make sure the SizeConstraint on defaultval is removed, and avoid more unnecessary commits. diff -r 2f684e538174 -r ce072c9aa573 misc/migration/3.18.0_Any.py --- a/misc/migration/3.18.0_Any.py Wed Jan 15 18:19:52 2014 +0100 +++ b/misc/migration/3.18.0_Any.py Wed Jan 15 18:20:25 2014 +0100 @@ -7,6 +7,12 @@ add_relation_definition('CWAttribute', 'add_permission', 'CWGroup') add_relation_definition('CWAttribute', 'add_permission', 'RQLExpression') +# the migration gets confused when we change rdefs out from under it. So +# explicitly remove this size constraint so it doesn't stick around and break +# things later. +rdefeid = schema['defaultval'].rdefs.values()[0].eid +rql('DELETE CWConstraint C WHERE C cstrtype T, T name "SizeConstraint", R constrained_by C, R eid %(eid)s', {'eid': rdefeid}) + sync_schema_props_perms('defaultval') def convert_defaultval(cwattr, default): @@ -65,12 +71,12 @@ rql('SET X to_entity B WHERE X is CWAttribute, X from_entity Y, Y name "CWAttribute", ' 'X relation_type Z, Z name "defaultval", B name "Bytes", NOT X to_entity B') -from yams import buildobjs as ybo -schema.add_relation_def(ybo.RelationDefinition('CWAttribute', 'defaultval', 'Bytes')) -schema.del_relation_def('CWAttribute', 'defaultval', 'String') +schema['defaultval'].rdefs.values()[0].object = schema['Bytes'] commit() +sync_schema_props_perms('defaultval') + for rschema in schema.relations(): if rschema.symmetric: subjects = set(repr(e.type) for e in rschema.subjects())