misc/migration/3.21.0_Any.py
changeset 10448 de5be53e2ea8
parent 10371 88577b10b31e
child 10482 88119421a09c
equal deleted inserted replaced
10447:d309c020d9fb 10448:de5be53e2ea8
    19 commit()
    19 commit()
    20 
    20 
    21 sync_schema_props_perms('CWEType')
    21 sync_schema_props_perms('CWEType')
    22 
    22 
    23 sync_schema_props_perms('cwuri')
    23 sync_schema_props_perms('cwuri')
       
    24 
       
    25 from cubicweb.server.schema2sql import check_constraint
       
    26 
       
    27 for cwconstraint in rql('Any C WHERE R constrained_by C').entities():
       
    28     cwrdef = cwconstraint.reverse_constrained_by[0]
       
    29     rdef = cwrdef.yams_schema()
       
    30     cstr = rdef.constraint_by_eid(cwconstraint.eid)
       
    31     if cstr.type() not in ('BoundaryConstraint', 'IntervalBoundConstraint', 'StaticVocabularyConstraint'):
       
    32         continue
       
    33     cstrname, check = check_constraint(rdef.subject, rdef.object, rdef.rtype.type,
       
    34             cstr, helper, prefix='cw_')
       
    35     sql('ALTER TABLE %s%s ADD CONSTRAINT %s CHECK(%s)' % ('cw_', rdef.subject.type, cstrname, check))
       
    36 commit()