Rename four logging indexes to have log_ prefix

To follow database coding convention and avoid clashes in RDBMS engines
where indexes are global

Bug: T270033
Change-Id: I17028bba489d04b01d22c39dc8935a4f0f771c7e
This commit is contained in:
Amir Sarabadani 2020-12-13 02:52:49 +01:00 committed by Ammarpad
parent d464f84182
commit 443c94de3f
10 changed files with 292 additions and 16 deletions

View file

@ -479,6 +479,7 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
'patch-user_properties-rename-index.sql' ],
[ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
[ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
];
}

View file

@ -890,6 +890,10 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'renameIndex', 'sites', 'sites_protocol', 'site_protocol' ],
[ 'renameIndex', 'sites', 'sites_domain', 'site_domain' ],
[ 'renameIndex', 'sites', 'sites_forward', 'site_forward' ],
[ 'renameIndex', 'logging', 'type_name', 'log_type_time' ],
[ 'renameIndex', 'logging', 'actor_time', 'log_actor_time' ],
[ 'renameIndex', 'logging', 'page_time', 'log_page_time' ],
[ 'renameIndex', 'logging', 'times', 'log_times' ],
];
}

View file

@ -323,6 +323,7 @@ class SqliteUpdater extends DatabaseUpdater {
[ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
'patch-user_properties-rename-index.sql' ],
[ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
[ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
];
}

View file

@ -0,0 +1,231 @@
{
"comment": "Rename several indexes in logging table to comply with database convention by having log_ prefix",
"before": {
"name": "logging",
"columns": [
{
"name": "log_id",
"comment": "Log ID, for referring to this specific log entry, probably for deletion and such.",
"type": "integer",
"options": { "unsigned": true, "notnull": true, "autoincrement": true }
},
{
"name": "log_type",
"comment": "Symbolic key for the general log type. The output format will be controlled by the log_action field.",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 32 }
},
{
"name": "log_action",
"comment": "Symbolic key for the log action type.",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 32 }
},
{
"name": "log_timestamp",
"type": "mwtimestamp",
"options": { "notnull": true, "default": "19700101000000" }
},
{
"name": "log_actor",
"type": "bigint",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "log_namespace",
"comment": "Key to the namespace of the page affected",
"type": "integer",
"options": { "notnull": true, "default": 0 }
},
{
"name": "log_title",
"comment": "Key to the title of the page affected",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 255 }
},
{
"name": "log_page",
"comment": "Key to the page affected",
"type": "integer",
"options": { "notnull": false, "unsigned": true }
},
{
"name": "log_comment_id",
"comment": "Key to comment_id. Comment summarizing the change.",
"type": "bigint",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "log_params",
"comment": "LF separated list (old system) or serialized PHP array (new system)",
"type": "blob",
"options": { "notnull": true, "length": 65530 }
},
{
"name": "log_deleted",
"comment": "rev_deleted for logs",
"type": "mwtinyint",
"options": { "notnull": true, "unsigned": true, "default": 0 }
}
],
"indexes": [
{
"name": "type_time",
"comment": "Special:Log type filter",
"columns": [ "log_type", "log_timestamp" ],
"unique": false
},
{
"name": "actor_time",
"comment": "Special:Log performer filter",
"columns": [ "log_actor", "log_timestamp" ],
"unique": false
},
{
"name": "page_time",
"comment": "Special:Log title filter, log extract",
"columns": [ "log_namespace", "log_title", "log_timestamp" ],
"unique": false
},
{
"name": "times",
"comment": "Special:Log unfiltered",
"columns": [ "log_timestamp" ],
"unique": false
},
{
"name": "log_actor_type_time",
"comment": "Special:Log filter by performer and type",
"columns": [ "log_actor", "log_type", "log_timestamp" ],
"unique": false
},
{
"name": "log_page_id_time",
"comment": "Apparently just used for a few maintenance pages (findMissingFiles.php, Flow). Could be removed?",
"columns": [ "log_page", "log_timestamp" ],
"unique": false
},
{
"name": "log_type_action",
"comment": "Special:Log action filter",
"columns": [ "log_type", "log_action", "log_timestamp" ],
"unique": false
}
],
"pk": [ "log_id" ]
},
"after": {
"name": "logging",
"columns": [
{
"name": "log_id",
"comment": "Log ID, for referring to this specific log entry, probably for deletion and such.",
"type": "integer",
"options": { "unsigned": true, "notnull": true, "autoincrement": true }
},
{
"name": "log_type",
"comment": "Symbolic key for the general log type. The output format will be controlled by the log_action field.",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 32 }
},
{
"name": "log_action",
"comment": "Symbolic key for the log action type.",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 32 }
},
{
"name": "log_timestamp",
"type": "mwtimestamp",
"options": { "notnull": true, "default": "19700101000000" }
},
{
"name": "log_actor",
"type": "bigint",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "log_namespace",
"comment": "Key to the namespace of the page affected",
"type": "integer",
"options": { "notnull": true, "default": 0 }
},
{
"name": "log_title",
"comment": "Key to the title of the page affected",
"type": "binary",
"options": { "notnull": true, "default": "", "length": 255 }
},
{
"name": "log_page",
"comment": "Key to the page affected",
"type": "integer",
"options": { "notnull": false, "unsigned": true }
},
{
"name": "log_comment_id",
"comment": "Key to comment_id. Comment summarizing the change.",
"type": "bigint",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "log_params",
"comment": "LF separated list (old system) or serialized PHP array (new system)",
"type": "blob",
"options": { "notnull": true, "length": 65530 }
},
{
"name": "log_deleted",
"comment": "rev_deleted for logs",
"type": "mwtinyint",
"options": { "notnull": true, "unsigned": true, "default": 0 }
}
],
"indexes": [
{
"name": "log_type_time",
"comment": "Special:Log type filter",
"columns": [ "log_type", "log_timestamp" ],
"unique": false
},
{
"name": "log_actor_time",
"comment": "Special:Log performer filter",
"columns": [ "log_actor", "log_timestamp" ],
"unique": false
},
{
"name": "log_page_time",
"comment": "Special:Log title filter, log extract",
"columns": [ "log_namespace", "log_title", "log_timestamp" ],
"unique": false
},
{
"name": "log_times",
"comment": "Special:Log unfiltered",
"columns": [ "log_timestamp" ],
"unique": false
},
{
"name": "log_actor_type_time",
"comment": "Special:Log filter by performer and type",
"columns": [ "log_actor", "log_type", "log_timestamp" ],
"unique": false
},
{
"name": "log_page_id_time",
"comment": "Apparently just used for a few maintenance pages (findMissingFiles.php, Flow). Could be removed?",
"columns": [ "log_page", "log_timestamp" ],
"unique": false
},
{
"name": "log_type_action",
"comment": "Special:Log action filter",
"columns": [ "log_type", "log_action", "log_timestamp" ],
"unique": false
}
],
"pk": [ "log_id" ]
}
}

View file

@ -0,0 +1,12 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-logging-rename-indexes.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX type_time ON /*_*/logging;
CREATE INDEX log_type_time ON /*_*/logging (log_type, log_timestamp);
DROP INDEX actor_time ON /*_*/logging;
CREATE INDEX log_actor_time ON /*_*/logging (log_actor, log_timestamp);
DROP INDEX page_time ON /*_*/logging;
CREATE INDEX log_page_time ON /*_*/logging ( log_namespace, log_title, log_timestamp );
DROP INDEX times ON /*_*/logging;
CREATE INDEX log_times ON /*_*/logging (log_timestamp);

View file

@ -594,15 +594,15 @@ CREATE TABLE logging (
PRIMARY KEY(log_id)
);
CREATE INDEX type_time ON logging (log_type, log_timestamp);
CREATE INDEX log_type_time ON logging (log_type, log_timestamp);
CREATE INDEX actor_time ON logging (log_actor, log_timestamp);
CREATE INDEX log_actor_time ON logging (log_actor, log_timestamp);
CREATE INDEX page_time ON logging (
CREATE INDEX log_page_time ON logging (
log_namespace, log_title, log_timestamp
);
CREATE INDEX times ON logging (log_timestamp);
CREATE INDEX log_times ON logging (log_timestamp);
CREATE INDEX log_actor_type_time ON logging (
log_actor, log_type, log_timestamp

View file

@ -0,0 +1,27 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-logging-rename-indexes.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX type_time;
DROP INDEX actor_time;
DROP INDEX page_time;
DROP INDEX times;
DROP INDEX log_actor_type_time;
DROP INDEX log_page_id_time;
DROP INDEX log_type_action;
CREATE TEMPORARY TABLE /*_*/__temp__logging AS
SELECT log_id, log_type, log_action, log_timestamp, log_actor, log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted
FROM /*_*/logging;
DROP TABLE /*_*/logging;
CREATE TABLE /*_*/logging ( log_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, log_type BLOB DEFAULT '' NOT NULL, log_action BLOB DEFAULT '' NOT NULL, log_timestamp BLOB DEFAULT '19700101000000' NOT NULL, log_actor BIGINT UNSIGNED NOT NULL, log_namespace INTEGER DEFAULT 0 NOT NULL, log_title BLOB DEFAULT '' NOT NULL, log_page INTEGER UNSIGNED DEFAULT NULL, log_comment_id BIGINT UNSIGNED NOT NULL, log_params BLOB NOT NULL, log_deleted SMALLINT UNSIGNED DEFAULT 0 NOT NULL );
INSERT INTO /*_*/logging ( log_id, log_type, log_action, log_timestamp, log_actor, log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted )
SELECT log_id, log_type, log_action, log_timestamp, log_actor, log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted
FROM /*_*/__temp__logging;
DROP TABLE /*_*/__temp__logging;
CREATE INDEX log_actor_type_time ON /*_*/logging ( log_actor, log_type, log_timestamp );
CREATE INDEX log_page_id_time ON /*_*/logging (log_page, log_timestamp);
CREATE INDEX log_type_action ON /*_*/logging ( log_type, log_action, log_timestamp );
CREATE INDEX log_type_time ON /*_*/logging (log_type, log_timestamp);
CREATE INDEX log_actor_time ON /*_*/logging (log_actor, log_timestamp);
CREATE INDEX log_page_time ON /*_*/logging ( log_namespace, log_title, log_timestamp );
CREATE INDEX log_times ON /*_*/logging (log_timestamp);

View file

@ -565,15 +565,15 @@ CREATE TABLE /*_*/logging (
log_params BLOB NOT NULL, log_deleted SMALLINT UNSIGNED DEFAULT 0 NOT NULL
);
CREATE INDEX type_time ON /*_*/logging (log_type, log_timestamp);
CREATE INDEX log_type_time ON /*_*/logging (log_type, log_timestamp);
CREATE INDEX actor_time ON /*_*/logging (log_actor, log_timestamp);
CREATE INDEX log_actor_time ON /*_*/logging (log_actor, log_timestamp);
CREATE INDEX page_time ON /*_*/logging (
CREATE INDEX log_page_time ON /*_*/logging (
log_namespace, log_title, log_timestamp
);
CREATE INDEX times ON /*_*/logging (log_timestamp);
CREATE INDEX log_times ON /*_*/logging (log_timestamp);
CREATE INDEX log_actor_type_time ON /*_*/logging (
log_actor, log_type, log_timestamp

View file

@ -527,12 +527,12 @@ CREATE TABLE /*_*/logging (
log_comment_id BIGINT UNSIGNED NOT NULL,
log_params BLOB NOT NULL,
log_deleted TINYINT UNSIGNED DEFAULT 0 NOT NULL,
INDEX type_time (log_type, log_timestamp),
INDEX actor_time (log_actor, log_timestamp),
INDEX page_time (
INDEX log_type_time (log_type, log_timestamp),
INDEX log_actor_time (log_actor, log_timestamp),
INDEX log_page_time (
log_namespace, log_title, log_timestamp
),
INDEX times (log_timestamp),
INDEX log_times (log_timestamp),
INDEX log_actor_type_time (
log_actor, log_type, log_timestamp
),

View file

@ -1715,25 +1715,25 @@
],
"indexes": [
{
"name": "type_time",
"name": "log_type_time",
"comment": "Special:Log type filter",
"columns": [ "log_type", "log_timestamp" ],
"unique": false
},
{
"name": "actor_time",
"name": "log_actor_time",
"comment": "Special:Log performer filter",
"columns": [ "log_actor", "log_timestamp" ],
"unique": false
},
{
"name": "page_time",
"name": "log_page_time",
"comment": "Special:Log title filter, log extract",
"columns": [ "log_namespace", "log_title", "log_timestamp" ],
"unique": false
},
{
"name": "times",
"name": "log_times",
"comment": "Special:Log unfiltered",
"columns": [ "log_timestamp" ],
"unique": false