-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore compatibility with SQLServer 2008 R2 in migrations #16627
Conversation
`ALTER TABLE DROP ... IF EXISTS ...` is only supported in SQL Server >16. The `IF EXISTS` here is a belt-and-braces and does not need to be present. Therefore can be dropped. We need to figure out some way of restricting our SQL syntax against the minimum version of SQL Server we will support. My suspicion is that `ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 100` may do that but there may be other side-effects so I am not whether to do that. Signed-off-by: Andrew Thornton <art27@cantab.net>
This seems to break migrations |
Should probably add that minimum version on CI and then run all migrations/tests against it, that should lead to CI failures in case of incompatible syntax. 2012 is the oldest version supported by MS, but I think only 2017 and above are available for Linux so we might need to set minimum version to 2017 to be able to test it. |
yup it does because it seems that we will need to check if the thing is a constraint or an index. Damn. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Codecov Report
@@ Coverage Diff @@
## main #16627 +/- ##
=======================================
Coverage 45.39% 45.40%
=======================================
Files 756 756
Lines 85279 85279
=======================================
+ Hits 38713 38717 +4
+ Misses 40306 40303 -3
+ Partials 6260 6259 -1
Continue to review full report at Codecov.
|
Ah that seems to be now working |
You can check if the index is exist at first. |
Line 854 only selects the indexes that exist. The |
Signed-off-by: Andrew Thornton <art27@cantab.net>
This fixes two problems with MSSQL:
ALTER TABLE DROP ... IF EXISTS ...
is only supported in SQL Server >16.The
IF EXISTS
here is a belt-and-braces and does not need to be present. Thereforecan be dropped. Also stop attempting to drop the indexes as constraints as they're indexes!
sys.indexes
should be lowercase not uppercase because of collation issues.Fix #16625
Fix #13615
Fix #16483
Signed-off-by: Andrew Thornton art27@cantab.net