From 1427bb1821e7f2e5dfbf68d929f369e4344ad884 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 14 Nov 2018 21:20:11 +0100 Subject: [PATCH] Drop ct_tag column from change_tag table Bug: T194163 Change-Id: I05d43510b51a67733b0107f0a768e261fe8ddabd --- includes/installer/MssqlUpdater.php | 3 +++ includes/installer/MysqlUpdater.php | 3 +++ includes/installer/OracleUpdater.php | 3 +++ includes/installer/PostgresUpdater.php | 3 +++ includes/installer/SqliteUpdater.php | 3 +++ maintenance/archives/patch-drop-ct_tag.sql | 10 ++++++++ .../mssql/archives/patch-drop-ct_tag.sql | 22 ++++++++++++++++++ maintenance/mssql/tables.sql | 9 +------- .../oracle/archives/patch-drop-ct_tag.sql | 9 ++++++++ maintenance/oracle/tables.sql | 8 +------ .../postgres/archives/patch-drop-ct_tag.sql | 10 ++++++++ maintenance/postgres/tables.sql | 8 +------ .../sqlite/archives/patch-drop-ct_tag.sql | 23 +++++++++++++++++++ maintenance/tables.sql | 10 ++------ 14 files changed, 94 insertions(+), 30 deletions(-) create mode 100644 maintenance/archives/patch-drop-ct_tag.sql create mode 100644 maintenance/mssql/archives/patch-drop-ct_tag.sql create mode 100644 maintenance/oracle/archives/patch-drop-ct_tag.sql create mode 100644 maintenance/postgres/archives/patch-drop-ct_tag.sql create mode 100644 maintenance/sqlite/archives/patch-drop-ct_tag.sql diff --git a/includes/installer/MssqlUpdater.php b/includes/installer/MssqlUpdater.php index 4a12d4cd99..db4cbdf39f 100644 --- a/includes/installer/MssqlUpdater.php +++ b/includes/installer/MssqlUpdater.php @@ -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' ], ]; } diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 82cf7f429d..532ccb03ae 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -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' ], ]; } diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index 78b53aab49..19c4cfe433 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -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' ], diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 71c1a52286..5730743b66 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -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' ], ]; } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index cba6a8a132..eb95b1c6ee 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -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 index 0000000000..2f5881a31e --- /dev/null +++ b/maintenance/archives/patch-drop-ct_tag.sql @@ -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 index 0000000000..5498a1c2a7 --- /dev/null +++ b/maintenance/mssql/archives/patch-drop-ct_tag.sql @@ -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; diff --git a/maintenance/mssql/tables.sql b/maintenance/mssql/tables.sql index ec2f1fa601..fd2fae79ce 100644 --- a/maintenance/mssql/tables.sql +++ b/maintenance/mssql/tables.sql @@ -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 index 0000000000..4c5d12845f --- /dev/null +++ b/maintenance/oracle/archives/patch-drop-ct_tag.sql @@ -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; diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index 1ccaabf335..4c36fe13e8 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -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 index 0000000000..cbef6c9077 --- /dev/null +++ b/maintenance/postgres/archives/patch-drop-ct_tag.sql @@ -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; + diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 96a061728e..4f636ae664 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -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 index 0000000000..d5fd77f87f --- /dev/null +++ b/maintenance/sqlite/archives/patch-drop-ct_tag.sql @@ -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); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 3c8b5981b8..72db8c3063 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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 -- 2.20.1