[hooks/syncschema] make sure CWUniqueTogetherConstraintDelOp happens before CWConstraintDelOp
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 23 Sep 2015 15:01:55 +0200
changeset 10586 22f330f829ae
parent 10585 80236876ee4d
child 10623 b9322cc17d7e
[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.
hooks/syncschema.py
--- a/hooks/syncschema.py	Wed Sep 23 15:00:33 2015 +0200
+++ b/hooks/syncschema.py	Wed Sep 23 15:01:55 2015 +0200
@@ -750,6 +750,13 @@
     entity = cstrname = None # for pylint
     cols = () # for pylint
 
+    def insert_index(self):
+        # We need to run before CWConstraintDelOp: if a size constraint is
+        # removed and the column is part of a unique_together constraint, we
+        # remove the unique_together index before changing the column's type.
+        # SQL Server does not support unique indices on unlimited text columns.
+        return 0
+
     def precommit_event(self):
         cnx = self.cnx
         prefix = SQL_PREFIX