[hooks/syncschema] make sure CWUniqueTogetherConstraintDelOp happens before CWConstraintDelOp

SQLServer refuses to index an unlimited text column, so we should drop unique_together constraints (which imply an index) before we drop size constraints. Closes #5560601.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset22f330f829ae
branchdefault
phasepublic
hiddenno
parent revision#80236876ee4d [hooks/syncschema] only call "ALTER TABLE" once when changing a size constraint
child revision#a2a4f0a41616 [hooks/test/synschema] remove an unneeded skipTest., #b9322cc17d7e [sources/native] fix potential NameError (closes #7364249)
files modified by this revision
hooks/syncschema.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1443013315 -7200
# Wed Sep 23 15:01:55 2015 +0200
# Node ID 22f330f829ae04c1b2a2b8f0f1e98f8a42716c74
# Parent 80236876ee4dd09d8a04a6909335b978f2ec0bfa
[hooks/syncschema] make sure CWUniqueTogetherConstraintDelOp happens before CWConstraintDelOp

SQLServer refuses to index an unlimited text column, so we should drop
unique_together constraints (which imply an index) before we drop size
constraints. Closes #5560601.

diff --git a/hooks/syncschema.py b/hooks/syncschema.py
@@ -748,10 +748,17 @@
1 
2  class CWUniqueTogetherConstraintDelOp(MemSchemaOperation):
3      entity = cstrname = None # for pylint
4      cols = () # for pylint
5 
6 +    def insert_index(self):
7 +        # We need to run before CWConstraintDelOp: if a size constraint is
8 +        # removed and the column is part of a unique_together constraint, we
9 +        # remove the unique_together index before changing the column's type.
10 +        # SQL Server does not support unique indices on unlimited text columns.
11 +        return 0
12 +
13      def precommit_event(self):
14          cnx = self.cnx
15          prefix = SQL_PREFIX
16          table = '%s%s' % (prefix, self.entity.type)
17          dbhelper = cnx.repo.system_source.dbhelper