[hooks/syncschema] do not crash on double removal of a constraint
Some complicated migrations may entail a double constraint removal.
It is not yet known whether this is a genuine cw bug or the result
of a complicated migration story, but we should nevertheless
not crash.
Rather, emit a CRITICAL warning and proceed.
Closes #3595309.
--- a/hooks/syncschema.py Fri Feb 14 17:52:49 2014 +0100
+++ b/hooks/syncschema.py Thu Feb 27 18:10:29 2014 +0100
@@ -676,7 +676,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')