Add ct_tag_id field to change_tag table

Part of normalizing the table

Bug: T193867
Change-Id: I8c38e673aab14c5b87e5501da1a752c5bd4709c8
This commit is contained in:
Amir Sarabadani 2018-05-11 21:16:37 +02:00
parent 369476d30e
commit f45314cd4f
12 changed files with 46 additions and 7 deletions

View file

@ -135,6 +135,7 @@ class MssqlUpdater extends DatabaseUpdater {
[ 'modifyfield', 'externallinks', 'el_index_60',
'patch-externallinks-el_index_60-drop-default.sql' ],
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
];
}

View file

@ -355,6 +355,7 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'modifyfield', 'externallinks', 'el_index_60',
'patch-externallinks-el_index_60-drop-default.sql' ],
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
];
}

View file

@ -152,6 +152,7 @@ class OracleUpdater extends DatabaseUpdater {
[ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
[ 'populateExternallinksIndex60' ],
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
// KEEP THIS AT THE BOTTOM!!
[ 'doRebuildDuplicateFunction' ],

View file

@ -575,6 +575,13 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'populateExternallinksIndex60' ],
[ 'dropDefault', 'externallinks', 'el_index_60' ],
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
[ 'addPgField', 'change_tag', 'ct_tag_id', 'INTEGER NULL' ],
[
'addPgIndex',
'change_tag',
'change_tag_tag_id_id',
'( ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id )'
],
];
}

View file

@ -219,6 +219,7 @@ class SqliteUpdater extends DatabaseUpdater {
[ 'modifyfield', 'externallinks', 'el_index_60',
'patch-externallinks-el_index_60-drop-default.sql' ],
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
];
}

View file

@ -0,0 +1,7 @@
--
-- Add ctd_tag_id to change_tag table to normalize it
--
ALTER TABLE /*_*/change_tag
ADD COLUMN ct_tag_id int unsigned NULL;
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

@ -0,0 +1,7 @@
--
-- Add ctd_tag_id to change_tag table to normalize it
--
ALTER TABLE /*_*/change_tag
ADD COLUMN ct_tag_id int NULL CONSTRAINT ctd_tag_id__fk FOREIGN KEY REFERENCES /*_*/change_tag_def(ctd_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

@ -1403,7 +1403,9 @@ CREATE TABLE /*_*/change_tag (
-- Tag applied
ct_tag nvarchar(255) NOT NULL,
-- Parameters for the tag, presently unused
ct_params nvarchar(max) NULL
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)
);
CREATE UNIQUE INDEX /*i*/change_tag_rc_tag ON /*_*/change_tag (ct_rc_id,ct_tag);
@ -1411,7 +1413,7 @@ CREATE UNIQUE INDEX /*i*/change_tag_log_tag ON /*_*/change_tag (ct_log_id,ct_tag
CREATE UNIQUE INDEX /*i*/change_tag_rev_tag ON /*_*/change_tag (ct_rev_id,ct_tag);
-- 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
-- that only works on MySQL 4.1+

View file

@ -0,0 +1,6 @@
--
-- Add ctd_tag_id to change_tag table to normalize it
--
ALTER TABLE &mw_prefix.change_tag ADD ( ct_tag_id NUMBER DEFAULT NULL );
CREATE INDEX &mw_prefix.change_tag_i02 ON &mw_prefix.change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);

View file

@ -942,13 +942,15 @@ CREATE TABLE &mw_prefix.change_tag (
ct_log_id NUMBER NULL,
ct_rev_id NUMBER NULL,
ct_tag VARCHAR2(255) NOT NULL,
ct_params BLOB NULL
ct_params BLOB NULL,
ct_tag_id NUMBER NULL,
);
ALTER TABLE &mw_prefix.change_tag ADD CONSTRAINT &mw_prefix.change_tag_pk PRIMARY KEY (ct_id);
CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
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 (
ts_id NUMBER NOT NULL,

View file

@ -807,13 +807,15 @@ CREATE TABLE change_tag (
ct_log_id INTEGER NULL,
ct_rev_id INTEGER NULL,
ct_tag TEXT NOT NULL,
ct_params TEXT NULL
ct_params TEXT NULL,
ct_tag_id INTEGER NULL
);
ALTER SEQUENCE change_tag_ct_id_seq OWNED BY change_tag.ct_id;
CREATE UNIQUE INDEX change_tag_rc_tag ON change_tag(ct_rc_id,ct_tag);
CREATE UNIQUE INDEX change_tag_log_tag ON change_tag(ct_log_id,ct_tag);
CREATE UNIQUE INDEX change_tag_rev_tag ON change_tag(ct_rev_id,ct_tag);
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;
CREATE TABLE tag_summary (

View file

@ -1842,10 +1842,12 @@ CREATE TABLE /*_*/change_tag (
ct_log_id int unsigned NULL,
-- REVID for the change
ct_rev_id int unsigned NULL,
-- Tag applied
-- Tag applied, this will go away and be replaced with ct_tag_id
ct_tag varchar(255) NOT NULL,
-- Parameters for the tag; used by some extensions
ct_params blob NULL
ct_params blob NULL,
-- Foreign key to change_tag_def row, this will be "NOT NULL" once populated
ct_tag_id int unsigned NULL
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/change_tag_rc_tag ON /*_*/change_tag (ct_rc_id,ct_tag);
@ -1853,7 +1855,7 @@ CREATE UNIQUE INDEX /*i*/change_tag_log_tag ON /*_*/change_tag (ct_log_id,ct_tag
CREATE UNIQUE INDEX /*i*/change_tag_rev_tag ON /*_*/change_tag (ct_rev_id,ct_tag);
-- 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
-- that only works on MySQL 4.1+