cubicweb/misc/migration/3.14.0_Any.py
changeset 11057 0b59724cb3f2
parent 10589 7c23b7de2b8d
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
       
     1 from __future__ import print_function
       
     2 
       
     3 config['rql-cache-size'] = config['rql-cache-size'] * 10
       
     4 
       
     5 add_entity_type('CWDataImport')
       
     6 
       
     7 from cubicweb.schema import CONSTRAINTS, guess_rrqlexpr_mainvars
       
     8 for rqlcstr in rql('Any X,XT,XV WHERE X is CWConstraint, X cstrtype XT, X value XV,'
       
     9                    'X cstrtype XT, XT name IN ("RQLUniqueConstraint","RQLConstraint","RQLVocabularyConstraint"),'
       
    10                    'NOT X value ~= ";%"').entities():
       
    11     expression = rqlcstr.value
       
    12     mainvars = guess_rrqlexpr_mainvars(expression)
       
    13     yamscstr = CONSTRAINTS[rqlcstr.type](expression, mainvars)
       
    14     rqlcstr.cw_set(value=yamscstr.serialize())
       
    15     print('updated', rqlcstr.type, rqlcstr.value.strip())