# HG changeset patch # User Julien Cristau # Date 1389806392 -3600 # Node ID 2f684e5381743fc80de3a88e7ad3f13be7688e03 # Parent f118541696546768c9b6144c155eb490be12b19f [migration/3.18] Idempotency fixes Try to make partially-upgraded instances migrate properly. diff -r f11854169654 -r 2f684e538174 misc/migration/3.18.0_Any.py --- a/misc/migration/3.18.0_Any.py Tue Jan 14 15:05:11 2014 +0100 +++ b/misc/migration/3.18.0_Any.py Wed Jan 15 18:19:52 2014 +0100 @@ -15,6 +15,9 @@ from cubicweb import Binary if default is None: return + if isinstance(default, Binary): + # partially migrated instance, try to be idempotent + return default atype = cwattr.to_entity[0].name if atype == 'Boolean': # boolean attributes with default=False were stored as '' @@ -60,7 +63,7 @@ # Set object type to "Bytes" for CWAttribute's "defaultval" attribute 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"') + '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'))