Drop ct_tag column from change_tag table

Bug: T194163
Change-Id: I05d43510b51a67733b0107f0a768e261fe8ddabd
This commit is contained in:
Amir Sarabadani 2018-11-14 21:20:11 +01:00 committed by Amir Sarabadani
parent 02a930d7fb
commit 1427bb1821
14 changed files with 94 additions and 30 deletions

View 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' ],
];
}

View 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' ],
];
}

View 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' ],

View 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' ],
];
}

View 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' ],
];
}

View file

@ -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;

View file

@ -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;

View 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

View file

@ -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;

View 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 (

View file

@ -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;

View 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;

View file

@ -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);

View 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