wiki.techinc.nl/maintenance/sqlite/archives/patch-logging-drop-log_comment.sql
Brad Jorsch 0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00

47 lines
2.2 KiB
PL/PgSQL

--
-- patch-logging-drop-log_comment.sql
--
-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
BEGIN;
DROP TABLE IF EXISTS /*_*/logging_tmp;
CREATE TABLE /*_*/logging_tmp (
log_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
log_type varbinary(32) NOT NULL default '',
log_action varbinary(32) NOT NULL default '',
log_timestamp binary(14) NOT NULL default '19700101000000',
log_user int unsigned NOT NULL default 0,
log_user_text varchar(255) binary NOT NULL default '',
log_actor bigint unsigned NOT NULL DEFAULT 0,
log_namespace int NOT NULL default 0,
log_title varchar(255) binary NOT NULL default '',
log_page int unsigned NULL,
log_comment_id bigint unsigned NOT NULL,
log_params blob NOT NULL,
log_deleted tinyint unsigned NOT NULL default 0
) /*$wgDBTableOptions*/;
INSERT OR IGNORE INTO /*_*/logging_tmp (
log_id, log_type, log_action, log_timestamp, log_user, log_user_text, 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_user, log_user_text, log_actor,
log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted
FROM /*_*/logging;
DROP TABLE /*_*/logging;
ALTER TABLE /*_*/logging_tmp RENAME TO /*_*/logging;
CREATE INDEX /*i*/type_time ON /*_*/logging (log_type, log_timestamp);
CREATE INDEX /*i*/user_time ON /*_*/logging (log_user, log_timestamp);
CREATE INDEX /*i*/actor_time ON /*_*/logging (log_actor, log_timestamp);
CREATE INDEX /*i*/page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
CREATE INDEX /*i*/times ON /*_*/logging (log_timestamp);
CREATE INDEX /*i*/log_user_type_time ON /*_*/logging (log_user, log_type, log_timestamp);
CREATE INDEX /*i*/log_actor_type_time ON /*_*/logging (log_actor, log_type, log_timestamp);
CREATE INDEX /*i*/log_page_id_time ON /*_*/logging (log_page,log_timestamp);
CREATE INDEX /*i*/log_type_action ON /*_*/logging (log_type, log_action, log_timestamp);
CREATE INDEX /*i*/log_user_text_type_time ON /*_*/logging (log_user_text, log_type, log_timestamp);
CREATE INDEX /*i*/log_user_text_time ON /*_*/logging (log_user_text, log_timestamp);
COMMIT;