Drop ct_tag column from change_tag table
authorAmir Sarabadani <Ladsgroup@gmail.com>
Wed, 14 Nov 2018 20:20:11 +0000 (21:20 +0100)
committerAmir Sarabadani <ladsgroup@gmail.com>
Wed, 28 Nov 2018 22:03:43 +0000 (23:03 +0100)
Bug: T194163
Change-Id: I05d43510b51a67733b0107f0a768e261fe8ddabd

14 files changed:
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/OracleUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php
maintenance/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/mssql/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/mssql/tables.sql
maintenance/oracle/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/oracle/tables.sql
maintenance/postgres/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/postgres/tables.sql
maintenance/sqlite/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/tables.sql

index 4a12d4c..db4cbdf 100644 (file)
@@ -152,6 +152,9 @@ class MssqlUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index 82cf7f4..532ccb0 100644 (file)
@@ -372,6 +372,9 @@ class MysqlUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1,33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index 78b53aa..19c4cfe 100644 (file)
@@ -164,6 +164,9 @@ class OracleUpdater extends DatabaseUpdater {
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
 
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
+
                        // KEEP THIS AT THE BOTTOM!!
                        [ 'doRebuildDuplicateFunction' ],
 
index 71c1a52..5730743 100644 (file)
@@ -598,6 +598,9 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index cba6a8a..eb95b1c 100644 (file)
@@ -237,6 +237,9 @@ class SqliteUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
diff --git a/maintenance/archives/patch-drop-ct_tag.sql b/maintenance/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..2f5881a
--- /dev/null
@@ -0,0 +1,10 @@
+-- T185355
+ALTER TABLE /*_*/change_tag MODIFY ct_tag_id int unsigned NOT NULL;
+
+DROP INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_tag_id ON /*_*/change_tag;
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
+
diff --git a/maintenance/mssql/archives/patch-drop-ct_tag.sql b/maintenance/mssql/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..5498a1c
--- /dev/null
@@ -0,0 +1,22 @@
+-- T185355
+ALTER TABLE /*_*/change_tag ALTER COLUMN ct_tag INTEGER NOT NULL
+
+DECLARE @sql nvarchar(max),
+       @id sysname;--
+
+SET @sql = 'ALTER TABLE /*_*/change_tag DROP CONSTRAINT ';--
+
+SELECT @id = df.name
+FROM sys.default_constraints df
+JOIN sys.columns c
+       ON c.object_id = df.parent_object_id
+       AND c.column_id = df.parent_column_id
+WHERE
+       df.parent_object_id = OBJECT_ID('/*_*/change_tag')
+       AND c.name = 'ct_tag';--
+
+SET @sql = @sql + @id;--
+
+EXEC sp_executesql @sql;--
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
index ec2f1fa..fd2fae7 100644 (file)
@@ -1398,24 +1398,17 @@ CREATE TABLE /*_*/change_tag (
   ct_log_id int NULL REFERENCES /*_*/logging(log_id),
   -- REVID for the change
   ct_rev_id int NULL REFERENCES /*_*/revision(rev_id),
-  -- Tag applied
-  ct_tag nvarchar(255) NOT NULL default '',
   -- Parameters for the tag, presently unused
   ct_params nvarchar(max) NULL,
   -- Foreign key to change_tag_def row
-  ct_tag_id int NULL CONSTRAINT ctd_tag_id__fk FOREIGN KEY REFERENCES /*_*/change_tag_def(ctd_id)
+  ct_tag_id int NOT NULL CONSTRAINT ctd_tag_id__fk FOREIGN KEY REFERENCES /*_*/change_tag_def(ctd_id)
 );
 
-CREATE INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag (ct_rc_id,ct_tag);
-CREATE INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag (ct_log_id,ct_tag);
-CREATE INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag (ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
 
 -- Covering index, so we can pull all the info only out of the index.
-CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT
diff --git a/maintenance/oracle/archives/patch-drop-ct_tag.sql b/maintenance/oracle/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..4c5d128
--- /dev/null
@@ -0,0 +1,9 @@
+-- T185355
+ALTER TABLE &mw_prefix.change_tag MODIFY &mw_prefix.ct_tag_id NUMBER NOT NULL;
+
+DROP INDEX &mw_prefix.change_tag_i03;
+DROP INDEX &mw_prefix.change_tag_i04;
+DROP INDEX &mw_prefix.change_tag_i05;
+DROP INDEX &mw_prefix.change_tag_i01;
+
+ALTER TABLE &mw_prefix.change_tag DROP COLUMN &mw_prefix.ct_tag;
index 1ccaabf..4c36fe1 100644 (file)
@@ -935,21 +935,15 @@ CREATE TABLE &mw_prefix.change_tag (
   ct_rc_id NUMBER NULL,
   ct_log_id NUMBER NULL,
   ct_rev_id NUMBER NULL,
-  ct_tag VARCHAR2(255) DEFAULT '///invalid///' NOT NULL,
   ct_params BLOB NULL,
-  ct_tag_id NUMBER NULL
+  ct_tag_id NUMBER NOT NULL
 );
 ALTER TABLE &mw_prefix.change_tag ADD CONSTRAINT &mw_prefix.change_tag_pk PRIMARY KEY (ct_id);
 
-CREATE INDEX &mw_prefix.change_tag_i03 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
-CREATE INDEX &mw_prefix.change_tag_i04 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
-CREATE INDEX &mw_prefix.change_tag_i05 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u04 ON &mw_prefix.change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u05 ON &mw_prefix.change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u06 ON &mw_prefix.change_tag (ct_rev_id,ct_tag_id);
 
-CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX &mw_prefix.change_tag_i02 ON &mw_prefix.change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 CREATE TABLE &mw_prefix.tag_summary (
diff --git a/maintenance/postgres/archives/patch-drop-ct_tag.sql b/maintenance/postgres/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..cbef6c9
--- /dev/null
@@ -0,0 +1,10 @@
+-- T185355
+ALTER TABLE /*_*/change_tag ALTER COLUMN ct_tag_id SET NOT NULL;
+
+DROP INDEX /*i*/change_tag_rc_tag_nonuniq;
+DROP INDEX /*i*/change_tag_log_tag_nonuniq;
+DROP INDEX /*i*/change_tag_rev_tag_nonuniq;
+DROP INDEX /*i*/change_tag_tag_id;
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
+
index 96a0617..4f636ae 100644 (file)
@@ -804,21 +804,15 @@ CREATE TABLE change_tag (
   ct_rc_id   INTEGER      NULL,
   ct_log_id  INTEGER      NULL,
   ct_rev_id  INTEGER      NULL,
-  ct_tag     TEXT     NOT NULL DEFAULT '',
   ct_params  TEXT         NULL,
-  ct_tag_id  INTEGER      NULL
+  ct_tag_id  INTEGER  NOT NULL
 );
 ALTER SEQUENCE change_tag_ct_id_seq OWNED BY change_tag.ct_id;
 
-CREATE INDEX change_tag_rc_tag_nonuniq ON change_tag(ct_rc_id,ct_tag);
-CREATE INDEX change_tag_log_tag_nonuniq ON change_tag(ct_log_id,ct_tag);
-CREATE INDEX change_tag_rev_tag_nonuniq ON change_tag(ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX change_tag_rc_tag_id ON change_tag(ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX change_tag_log_tag_id ON change_tag(ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX change_tag_rev_tag_id ON change_tag(ct_rev_id,ct_tag_id);
 
-CREATE INDEX change_tag_tag_id ON change_tag(ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX change_tag_tag_id_id ON change_tag(ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 CREATE SEQUENCE tag_summary_ts_id_seq;
diff --git a/maintenance/sqlite/archives/patch-drop-ct_tag.sql b/maintenance/sqlite/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..d5fd77f
--- /dev/null
@@ -0,0 +1,23 @@
+-- T185355
+
+CREATE TABLE /*_*/change_tag_tmp (
+  ct_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  ct_rc_id int NULL,
+  ct_log_id int unsigned NULL,
+  ct_rev_id int unsigned NULL,
+  ct_params blob NULL,
+  ct_tag_id int unsigned NOT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/change_tag_tmp
+       SELECT ct_id, ct_rc_id, ct_log_id, ct_rev_id, ct_params, ct_tag_id
+               FROM /*_*/change_tag;
+
+DROP TABLE /*_*/change_tag;
+
+ALTER TABLE /*_*/change_tag_tmp RENAME TO /*_*/change_tag;
+
+CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
+CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
+CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
+CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
index 3c8b598..72db8c3 100644 (file)
@@ -1846,23 +1846,17 @@ CREATE TABLE /*_*/change_tag (
   ct_log_id int unsigned NULL,
   -- REVID for the change
   ct_rev_id int unsigned NULL,
-  -- Tag applied, this will go away and be replaced with ct_tag_id
-  ct_tag varchar(255) NOT NULL default '',
   -- Parameters for the tag; used by some extensions
   ct_params blob NULL,
-  -- Foreign key to change_tag_def row, this will be "NOT NULL" once populated
-  ct_tag_id int unsigned NULL
+  -- Foreign key to change_tag_def row
+  ct_tag_id int unsigned NOT NULL
 ) /*$wgDBTableOptions*/;
 
-CREATE INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag (ct_rc_id,ct_tag);
-CREATE INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag (ct_log_id,ct_tag);
-CREATE INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag (ct_rev_id,ct_tag);
 
 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
 -- Covering index, so we can pull all the info only out of the index.
-CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT