summaryrefslogtreecommitdiff
path: root/maintenance/mssql/archives
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/mssql/archives')
-rw-r--r--maintenance/mssql/archives/named_constraints.sql38
-rw-r--r--maintenance/mssql/archives/patch-fa_major_mime-chemical.sql4
-rw-r--r--maintenance/mssql/archives/patch-img_major_mime-chemical.sql4
-rw-r--r--maintenance/mssql/archives/patch-oi_major_mime-chemical.sql4
-rw-r--r--maintenance/mssql/archives/patch-page_page_lang.sql1
-rw-r--r--maintenance/mssql/archives/patch-user_password_expires.sql1
6 files changed, 52 insertions, 0 deletions
diff --git a/maintenance/mssql/archives/named_constraints.sql b/maintenance/mssql/archives/named_constraints.sql
new file mode 100644
index 00000000..94b77ea7
--- /dev/null
+++ b/maintenance/mssql/archives/named_constraints.sql
@@ -0,0 +1,38 @@
+DECLARE @fullyQualifiedTableName nvarchar(max),
+@tableName sysname,
+@fieldName sysname,
+@constr sysname,
+@constrNew sysname,
+@sqlcmd nvarchar(max),
+@sqlcreate nvarchar(max)
+
+SET @fullyQualifiedTableName = '/*_*//*$tableName*/'
+SET @tableName = '/*$tableName*/'
+SET @fieldName = '/*$fieldName*/'
+
+SELECT @constr = CONSTRAINT_NAME
+FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
+WHERE TABLE_NAME = @tableName
+AND CONSTRAINT_CATALOG = '/*$wgDBname*/'
+AND CONSTRAINT_SCHEMA = '/*$wgDBmwschema*/'
+AND CONSTRAINT_TYPE = 'CHECK'
+AND CONSTRAINT_NAME LIKE ('CK__' + left(@tableName,9) + '__' + left(@fieldName,5) + '%')
+
+SELECT @constrNew = CONSTRAINT_NAME
+FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
+WHERE TABLE_NAME = @tableName
+AND CONSTRAINT_CATALOG = '/*$wgDBname*/'
+AND CONSTRAINT_SCHEMA = '/*$wgDBmwschema*/'
+AND CONSTRAINT_TYPE = 'CHECK'
+AND CONSTRAINT_NAME = (@fieldName + '_ckc')
+
+IF @constr IS NOT NULL
+BEGIN
+ SET @sqlcmd = 'ALTER TABLE ' + @fullyQualifiedTableName + ' DROP CONSTRAINT [' + @constr + ']'
+ EXECUTE sp_executesql @sqlcmd
+END
+IF @constrNew IS NULL
+BEGIN
+ SET @sqlcreate = 'ALTER TABLE ' + @fullyQualifiedTableName + ' WITH NOCHECK ADD CONSTRAINT ' + @fieldName + '_ckc CHECK /*$checkConstraint*/;'
+ EXECUTE sp_executesql @sqlcreate
+END \ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-fa_major_mime-chemical.sql b/maintenance/mssql/archives/patch-fa_major_mime-chemical.sql
new file mode 100644
index 00000000..18368087
--- /dev/null
+++ b/maintenance/mssql/archives/patch-fa_major_mime-chemical.sql
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/filearchive
+DROP CONSTRAINT fa_major_mime_ckc;
+ALTER TABLE /*_*/filearchive
+WITH NOCHECK ADD CONSTRAINT fa_major_mime_ckc CHECK (fa_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')); \ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-img_major_mime-chemical.sql b/maintenance/mssql/archives/patch-img_major_mime-chemical.sql
new file mode 100644
index 00000000..eed07869
--- /dev/null
+++ b/maintenance/mssql/archives/patch-img_major_mime-chemical.sql
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/image
+DROP CONSTRAINT img_major_mime_ckc;
+ALTER TABLE /*_*/image
+WITH NOCHECK ADD CONSTRAINT img_major_mime_ckc CHECK (img_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')); \ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-oi_major_mime-chemical.sql b/maintenance/mssql/archives/patch-oi_major_mime-chemical.sql
new file mode 100644
index 00000000..35482edc
--- /dev/null
+++ b/maintenance/mssql/archives/patch-oi_major_mime-chemical.sql
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/oldimage
+DROP CONSTRAINT oi_major_mime_ckc;
+ALTER TABLE /*_*/oldimage
+WITH NOCHECK ADD CONSTRAINT oi_major_mime_ckc CHECK (oi_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')); \ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-page_page_lang.sql b/maintenance/mssql/archives/patch-page_page_lang.sql
new file mode 100644
index 00000000..d2f537b0
--- /dev/null
+++ b/maintenance/mssql/archives/patch-page_page_lang.sql
@@ -0,0 +1 @@
+ALTER TABLE /*_*/page ADD page_lang VARBINARY(35) DEFAULT NULL
diff --git a/maintenance/mssql/archives/patch-user_password_expires.sql b/maintenance/mssql/archives/patch-user_password_expires.sql
new file mode 100644
index 00000000..c22b10c7
--- /dev/null
+++ b/maintenance/mssql/archives/patch-user_password_expires.sql
@@ -0,0 +1 @@
+ALTER TABLE /*_*/mwuser ADD user_password_expires VARCHAR(14) DEFAULT NULL \ No newline at end of file