Rename namespace_title index on watchlist to wl_namespace_title

Indexes need to have prefixes, to avoid clashes in several RDBMSes where
indexes are global

Bug: T266228
Change-Id: I96a04903f6123d1fb8081fcf15cdd1f29708d320
This commit is contained in:
Amir Sarabadani 2020-11-16 15:24:24 +01:00
parent 5ed40a2c1d
commit db4315b942
10 changed files with 141 additions and 4 deletions

View file

@ -464,6 +464,8 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'dropDefault', 'ip_changes', 'ipc_rev_timestamp' ],
[ 'dropDefault', 'revision_actor_temp', 'revactor_timestamp' ],
[ 'modifyField', 'ipblocks_restrictions', 'ir_type', 'patch-ipblocks_restrictions-ir_type.sql' ],
[ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
'patch-watchlist-namespace_title-rename-index.sql' ],
];
}

View file

@ -815,6 +815,7 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'dropFkey', 'revision_actor_temp', 'revactor_page' ],
[ 'changeField', 'revision_actor_temp', 'revactor_actor', 'BIGINT', '' ],
[ 'changeNullableField', 'revision_actor_temp', 'revactor_page', 'NOT NULL', true ],
[ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title' ],
];
}

View file

@ -313,6 +313,8 @@ class SqliteUpdater extends DatabaseUpdater {
[ 'modifyField', 'protected_titles', 'pt_expiry', 'patch-protected_titles-pt_expiry-drop-default.sql' ],
[ 'modifyField', 'ip_changes', 'ipc_rev_timestamp', 'patch-ip_changes-pc_rev_timestamp-drop-default.sql' ],
[ 'modifyField', 'revision_actor_temp', 'revactor_timestamp', 'patch-revactor_timestamp-drop-default.sql' ],
[ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
'patch-watchlist-namespace_title-rename-index.sql' ],
];
}

View file

@ -0,0 +1,107 @@
{
"comment": "Rename namespace_title index to wl_namespace_title on watchlist (T266228)",
"before": {
"name": "watchlist",
"columns": [
{
"name": "wl_id",
"type": "integer",
"options": { "unsigned": true, "notnull": true, "autoincrement": true }
},
{
"name": "wl_user",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "wl_namespace",
"type": "integer",
"options": { "notnull": true, "unsigned": false, "default": 0 }
},
{
"name": "wl_title",
"type": "binary",
"options": { "length": 255, "notnull": true, "default": "" }
},
{
"name": "wl_notificationtimestamp",
"comment": "Timestamp used to send notification e-mails and show 'updated since last visit' markers. Set to NULL when the user visits the latest revision of the page, which means that they should be sent an e-mail on the next change.",
"type": "mwtimestamp",
"options": { "notnull": false }
}
],
"indexes": [
{
"name": "wl_user",
"columns": [ "wl_user", "wl_namespace", "wl_title" ],
"comment": "Special:Watchlist",
"unique": true
},
{
"name": "namespace_title",
"columns": [ "wl_namespace", "wl_title" ],
"comment": "Special:Movepage (WatchedItemStore::duplicateEntry)",
"unique": false
},
{
"name": "wl_user_notificationtimestamp",
"columns": [ "wl_user", "wl_notificationtimestamp" ],
"comment": "ApiQueryWatchlistRaw changed filter",
"unique": false
}
],
"pk": [ "wl_id" ]
},
"after": {
"name": "watchlist",
"columns": [
{
"name": "wl_id",
"type": "integer",
"options": { "unsigned": true, "notnull": true, "autoincrement": true }
},
{
"name": "wl_user",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "wl_namespace",
"type": "integer",
"options": { "notnull": true, "unsigned": false, "default": 0 }
},
{
"name": "wl_title",
"type": "binary",
"options": { "length": 255, "notnull": true, "default": "" }
},
{
"name": "wl_notificationtimestamp",
"comment": "Timestamp used to send notification e-mails and show 'updated since last visit' markers. Set to NULL when the user visits the latest revision of the page, which means that they should be sent an e-mail on the next change.",
"type": "mwtimestamp",
"options": { "notnull": false }
}
],
"indexes": [
{
"name": "wl_user",
"columns": [ "wl_user", "wl_namespace", "wl_title" ],
"comment": "Special:Watchlist",
"unique": true
},
{
"name": "wl_namespace_title",
"columns": [ "wl_namespace", "wl_title" ],
"comment": "Special:Movepage (WatchedItemStore::duplicateEntry)",
"unique": false
},
{
"name": "wl_user_notificationtimestamp",
"columns": [ "wl_user", "wl_notificationtimestamp" ],
"comment": "ApiQueryWatchlistRaw changed filter",
"unique": false
}
],
"pk": [ "wl_id" ]
}
}

View file

@ -0,0 +1,6 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-watchlist-namespace_title-rename-index.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX namespace_title ON /*_*/watchlist;
CREATE INDEX wl_namespace_title ON /*_*/watchlist (wl_namespace, wl_title);

View file

@ -360,7 +360,7 @@ CREATE TABLE watchlist (
CREATE UNIQUE INDEX wl_user ON watchlist (wl_user, wl_namespace, wl_title);
CREATE INDEX namespace_title ON watchlist (wl_namespace, wl_title);
CREATE INDEX wl_namespace_title ON watchlist (wl_namespace, wl_title);
CREATE INDEX wl_user_notificationtimestamp ON watchlist (
wl_user, wl_notificationtimestamp

View file

@ -0,0 +1,19 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-watchlist-namespace_title-rename-index.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX wl_user;
DROP INDEX namespace_title;
DROP INDEX wl_user_notificationtimestamp;
CREATE TEMPORARY TABLE /*_*/__temp__watchlist AS
SELECT wl_id, wl_user, wl_namespace, wl_title, wl_notificationtimestamp
FROM /*_*/watchlist;
DROP TABLE /*_*/watchlist;
CREATE TABLE /*_*/watchlist ( wl_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, wl_user INTEGER UNSIGNED NOT NULL, wl_namespace INTEGER DEFAULT 0 NOT NULL, wl_title BLOB DEFAULT '' NOT NULL, wl_notificationtimestamp BLOB DEFAULT NULL );
INSERT INTO /*_*/watchlist ( wl_id, wl_user, wl_namespace, wl_title, wl_notificationtimestamp )
SELECT wl_id, wl_user, wl_namespace, wl_title, wl_notificationtimestamp
FROM /*_*/__temp__watchlist;
DROP TABLE /*_*/__temp__watchlist;
CREATE UNIQUE INDEX wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
CREATE INDEX wl_user_notificationtimestamp ON /*_*/watchlist ( wl_user, wl_notificationtimestamp );
CREATE INDEX wl_namespace_title ON /*_*/watchlist (wl_namespace, wl_title);

View file

@ -344,7 +344,7 @@ CREATE TABLE /*_*/watchlist (
CREATE UNIQUE INDEX wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
CREATE INDEX namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
CREATE INDEX wl_namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
CREATE INDEX wl_user_notificationtimestamp ON /*_*/watchlist (
wl_user, wl_notificationtimestamp

View file

@ -319,7 +319,7 @@ CREATE TABLE /*_*/watchlist (
wl_title VARBINARY(255) DEFAULT '' NOT NULL,
wl_notificationtimestamp BINARY(14) DEFAULT NULL,
UNIQUE INDEX wl_user (wl_user, wl_namespace, wl_title),
INDEX namespace_title (wl_namespace, wl_title),
INDEX wl_namespace_title (wl_namespace, wl_title),
INDEX wl_user_notificationtimestamp (
wl_user, wl_notificationtimestamp
),

View file

@ -1062,7 +1062,7 @@
"unique": true
},
{
"name": "namespace_title",
"name": "wl_namespace_title",
"columns": [ "wl_namespace", "wl_title" ],
"comment": "Special:Movepage (WatchedItemStore::duplicateEntry)",
"unique": false