--- a/hooks/syncschema.py Tue Apr 01 14:46:55 2014 +0200
+++ b/hooks/syncschema.py Tue Apr 01 18:09:46 2014 +0200
@@ -650,7 +650,11 @@
rdef = self.rdef
# in-place modification of in-memory schema first
_set_modifiable_constraints(rdef)
- rdef.constraints.remove(self.oldcstr)
+ if self.oldcstr in rdef.constraints:
+ rdef.constraints.remove(self.oldcstr)
+ else:
+ self.critical('constraint %s for rdef %s was missing or already removed',
+ self.oldcstr, rdef)
# then update database: alter the physical schema on size/unique
# constraint changes
syssource = session.cnxset.source('system')
@@ -1132,12 +1136,11 @@
if self._cw.deleted_in_transaction(self.eidfrom):
return
schema = self._cw.vreg.schema
- entity = self._cw.entity_from_eid(self.eidto)
rdef = schema.schema_by_eid(self.eidfrom)
try:
- cstr = rdef.constraint_by_type(entity.type)
- except IndexError:
- self._cw.critical('constraint type no more accessible')
+ cstr = rdef.constraint_by_eid(self.eidto)
+ except ValueError:
+ self._cw.critical('constraint no more accessible')
else:
CWConstraintDelOp(self._cw, rdef=rdef, oldcstr=cstr)