misc/migration/bootstrapmigration_repository.py
changeset 10015 57a16bef82c0
parent 9708 b36bc18f6ef7
child 10025 7b72ecc3f4d2
equal deleted inserted replaced
10014:74b793086067 10015:57a16bef82c0
   252             {'extid': b64encode(extid), 'eid': eid}, ask_confirm=False)
   252             {'extid': b64encode(extid), 'eid': eid}, ask_confirm=False)
   253     commit()
   253     commit()
   254 
   254 
   255 if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0):
   255 if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0):
   256     add_cube('card', update_database=False)
   256     add_cube('card', update_database=False)
       
   257 
       
   258 def sync_constraint_types():
       
   259     """Make sure the repository knows about all constraint types defined in the code"""
       
   260     from cubicweb.schema import CONSTRAINTS
       
   261     repo_constraints = set(row[0] for row in rql('Any N WHERE X is CWConstraintType, X name N'))
       
   262 
       
   263     for cstrtype in set(CONSTRAINTS) - repo_constraints:
       
   264         if cstrtype == 'BoundConstraint':
       
   265             # was renamed to BoundaryConstraint, we don't need the old name
       
   266             continue
       
   267         rql('INSERT CWConstraintType X: X name %(name)s', {'name': cstrtype})
       
   268 
       
   269     commit()
       
   270 
       
   271 sync_constraint_types()