[migration/3.18] Explicitly delete constraint on defaultval
Make sure the SizeConstraint on defaultval is removed, and avoid more
unnecessary commits.
--- 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())