[PATCH seda] [migration] Add migration script to synchronize compound etypes / relations

Sylvain Thénault sylvain.thenault at logilab.fr
Wed Jun 14 10:24:12 CEST 2017



Le 14/06/2017 à 10:08, Philippe Pepiot a écrit :
> On 06/13/2017 02:35 PM, Sylvain Thenault wrote:
>> # HG changeset patch
>> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
>> # Date 1497356950 -7200
>> #      Tue Jun 13 14:29:10 2017 +0200
>> # Node ID 200a504883dcca3369eeb79f68f7fbdecd2f5e5f
>> # Parent  50fc4ed12eae04aa395e78f8e01ceeffc1e83886
>> # Available At https://hg.logilab.org/review/cubes/seda
>> #              hg pull https://hg.logilab.org/review/cubes/seda -r 200a504883dc
>> [migration] Add migration script to synchronize compound etypes / relations
>>
>>
>> missed by 8f1a4f7abbf6
>>
>> Related to extranet #25271719
>>
>> diff --git a/cubicweb_seda/migration/0.10.4_Any.py b/cubicweb_seda/migration/0.10.4_Any.py
>> new file mode 100644
>> --- /dev/null
>> +++ b/cubicweb_seda/migration/0.10.4_Any.py
>> @@ -0,0 +1,10 @@
>> +from cubicweb_seda import seda_profile_container_def, iter_all_rdefs
>> +
>> +for etype, parent_rdefs in seda_profile_container_def(schema):
>> +    sync_schema_props_perms(etype, syncprops=False)
>> +for rdef, role in iter_all_rdefs(schema, 'SEDAArchiveTransfer'):
>> +    try:
>> +        sync_schema_props_perms((rdef.subject, rdef.rtype, rdef.object),
>> +                                syncprops=False)
>> +    except KeyError:
>> +        print('junk detected in database schema', rdef)
>>
> Under what circumstances the KeyError is raised ? KeyError seems too
> generic here, couldn't this be checked without needing the try/except
> block ?
This occurs when there are deprecated schema bits in the database which
do not actually exists anymore in the code. This may be checked more
specifically.

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list