server/migractions.py
branchstable
changeset 4633 a85b4361fb22
parent 4580 9fce32b5d219
child 4640 1b83a25cf9f5
equal deleted inserted replaced
4632:8ac40462bad0 4633:a85b4361fb22
   662         # have to commit this first step anyway to get the definition
   662         # have to commit this first step anyway to get the definition
   663         # actually in the schema
   663         # actually in the schema
   664         self.cmd_add_attribute(etype, newname, attrtype, commit=True)
   664         self.cmd_add_attribute(etype, newname, attrtype, commit=True)
   665         # skipp NULL values if the attribute is required
   665         # skipp NULL values if the attribute is required
   666         rql = 'SET X %s VAL WHERE X is %s, X %s VAL' % (newname, etype, oldname)
   666         rql = 'SET X %s VAL WHERE X is %s, X %s VAL' % (newname, etype, oldname)
   667         card = eschema.rproperty(newname, 'cardinality')[0]
   667         card = eschema.rdef(newname).cardinality[0]
   668         if card == '1':
   668         if card == '1':
   669             rql += ', NOT X %s NULL' % oldname
   669             rql += ', NOT X %s NULL' % oldname
   670         self.rqlexec(rql, ask_confirm=self.verbosity>=2)
   670         self.rqlexec(rql, ask_confirm=self.verbosity>=2)
   671         # XXX if both attributes fulltext indexed, should skip fti rebuild
   671         # XXX if both attributes fulltext indexed, should skip fti rebuild
   672         # XXX if old attribute was fti indexed but not the new one old value
   672         # XXX if old attribute was fti indexed but not the new one old value
   733                                 # simply skip here
   733                                 # simply skip here
   734                                 continue
   734                                 continue
   735                         elif role == 'object':
   735                         elif role == 'object':
   736                             subjschema = tschema
   736                             subjschema = tschema
   737                             objschema = spschema
   737                             objschema = spschema
   738                         if (rschema.rproperty(subjschema, objschema, 'infered')
   738                         if (rschema.rdef(subjschema, objschema).infered
   739                             or (instschema.has_relation(rschema) and
   739                             or (instschema.has_relation(rschema) and
   740                                 instschema[rschema].has_rdef(subjschema, objschema))):
   740                                 (subjschema, objschema) in instschema[rschema].rdefs)):
   741                                 continue
   741                                 continue
   742                         self.cmd_add_relation_definition(
   742                         self.cmd_add_relation_definition(
   743                             subjschema.type, rschema.type, objschema.type)
   743                             subjschema.type, rschema.type, objschema.type)
   744         if auto:
   744         if auto:
   745             # we have commit here to get relation types actually in the schema
   745             # we have commit here to get relation types actually in the schema