From 5d4a012d484bae5a881afd0e8b8e3ae6286a17f9 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 27 Jun 2021 22:43:11 +0100 Subject: [PATCH] Drop DB patches from pre MW 1.26 Change-Id: I6693239455a2696b7bb77841041204b75a3c99fb --- db_patches/echo_email_batch.sql | 9 --- db_patches/echo_target_page.sql | 8 --- .../patch-drop-echo_event-event_timestamp.sql | 1 - db_patches/mysql/patch-event_agent-split.sql | 4 -- .../mysql/patch-event_agent_ip-size.sql | 2 - db_patches/mysql/patch-event_extra-size.sql | 2 - .../mysql/patch-event_variant_nullability.sql | 1 - .../mysql/patch-multiple_target_pages.sql | 3 - .../patch-add-echo_event-event_page_id.sql | 1 - db_patches/patch-alter-event_type-index.sql | 3 - db_patches/patch-alter-type_page-index.sql | 3 - .../patch-alter-user_timestamp-index.sql | 2 - db_patches/patch-drop-echo_subscription.sql | 2 - db_patches/patch-email_batch-new-field.sql | 7 --- .../patch-notification-bundling-field.sql | 8 --- .../sqlite/patch-event_agent-split.sqlite.sql | 34 ----------- .../patch-event_variant_nullability.sql | 33 ----------- .../sqlite/patch-multiple_target_pages.sql | 27 --------- includes/EchoHooks.php | 57 ++----------------- 19 files changed, 4 insertions(+), 203 deletions(-) delete mode 100644 db_patches/echo_email_batch.sql delete mode 100644 db_patches/echo_target_page.sql delete mode 100644 db_patches/mysql/patch-drop-echo_event-event_timestamp.sql delete mode 100644 db_patches/mysql/patch-event_agent-split.sql delete mode 100644 db_patches/mysql/patch-event_agent_ip-size.sql delete mode 100644 db_patches/mysql/patch-event_extra-size.sql delete mode 100644 db_patches/mysql/patch-event_variant_nullability.sql delete mode 100644 db_patches/mysql/patch-multiple_target_pages.sql delete mode 100644 db_patches/patch-add-echo_event-event_page_id.sql delete mode 100644 db_patches/patch-alter-event_type-index.sql delete mode 100644 db_patches/patch-alter-type_page-index.sql delete mode 100644 db_patches/patch-alter-user_timestamp-index.sql delete mode 100644 db_patches/patch-drop-echo_subscription.sql delete mode 100644 db_patches/patch-email_batch-new-field.sql delete mode 100644 db_patches/patch-notification-bundling-field.sql delete mode 100644 db_patches/sqlite/patch-event_agent-split.sqlite.sql delete mode 100644 db_patches/sqlite/patch-event_variant_nullability.sql delete mode 100644 db_patches/sqlite/patch-multiple_target_pages.sql diff --git a/db_patches/echo_email_batch.sql b/db_patches/echo_email_batch.sql deleted file mode 100644 index 825eec004..000000000 --- a/db_patches/echo_email_batch.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE /*_*/echo_email_batch ( - eeb_id int unsigned not null primary key auto_increment, - eeb_user_id int unsigned not null, - eeb_event_priority tinyint unsigned not null default 10, -- event priority - eeb_event_id int unsigned not null -) /*$wgDBTableOptions*/; - -CREATE UNIQUE INDEX /*i*/echo_email_batch_user_event ON /*_*/echo_email_batch (eeb_user_id,eeb_event_id); -CREATE UNIQUE INDEX /*i*/echo_email_batch_user_priority_event ON /*_*/echo_email_batch (eeb_user_id,eeb_event_priority,eeb_event_id); diff --git a/db_patches/echo_target_page.sql b/db_patches/echo_target_page.sql deleted file mode 100644 index f6e5c4a2a..000000000 --- a/db_patches/echo_target_page.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE /*_*/echo_target_page ( - etp_user int unsigned not null default 0, - etp_page int unsigned not null default 0, - etp_event int unsigned not null default 0 -) /*$wgDBTableOptions*/; - -CREATE UNIQUE INDEX /*i*/echo_target_page_user_event ON /*_*/echo_target_page (etp_user, etp_event); -CREATE INDEX /*i*/echo_target_page_user_page_event ON /*_*/echo_target_page (etp_user, etp_page, etp_event); diff --git a/db_patches/mysql/patch-drop-echo_event-event_timestamp.sql b/db_patches/mysql/patch-drop-echo_event-event_timestamp.sql deleted file mode 100644 index 57f6331ac..000000000 --- a/db_patches/mysql/patch-drop-echo_event-event_timestamp.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE /*_*/echo_event DROP event_timestamp; diff --git a/db_patches/mysql/patch-event_agent-split.sql b/db_patches/mysql/patch-event_agent-split.sql deleted file mode 100644 index b543e858c..000000000 --- a/db_patches/mysql/patch-event_agent-split.sql +++ /dev/null @@ -1,4 +0,0 @@ --- 2012-05-06: Split event_agent field to allow anonymous agents. - -ALTER TABLE echo_event CHANGE COLUMN event_agent event_agent_id int unsigned null; -ALTER TABLE echo_event ADD COLUMN event_agent_ip varchar(255) binary null; \ No newline at end of file diff --git a/db_patches/mysql/patch-event_agent_ip-size.sql b/db_patches/mysql/patch-event_agent_ip-size.sql deleted file mode 100644 index 5ba0bb2c2..000000000 --- a/db_patches/mysql/patch-event_agent_ip-size.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Patch to update ip size from varbinary(255) to varbinary(39) -ALTER TABLE /*_*/echo_event CHANGE COLUMN event_agent_ip event_agent_ip varchar(39) binary NULL; diff --git a/db_patches/mysql/patch-event_extra-size.sql b/db_patches/mysql/patch-event_extra-size.sql deleted file mode 100644 index 0f67672f2..000000000 --- a/db_patches/mysql/patch-event_extra-size.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Patch to add extra space to event_extra -alter table /*_*/echo_event change column event_extra event_extra BLOB NULL; \ No newline at end of file diff --git a/db_patches/mysql/patch-event_variant_nullability.sql b/db_patches/mysql/patch-event_variant_nullability.sql deleted file mode 100644 index 4a1d5e0cf..000000000 --- a/db_patches/mysql/patch-event_variant_nullability.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE /*_*/echo_event CHANGE COLUMN event_variant event_variant varchar(64) binary null; \ No newline at end of file diff --git a/db_patches/mysql/patch-multiple_target_pages.sql b/db_patches/mysql/patch-multiple_target_pages.sql deleted file mode 100644 index 5d574f95d..000000000 --- a/db_patches/mysql/patch-multiple_target_pages.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE /*_*/echo_target_page ADD etp_id int unsigned not null primary key auto_increment; -DROP INDEX /*i*/echo_target_page_user_event ON /*_*/echo_target_page; -CREATE INDEX /*i*/echo_target_page_user_event ON /*_*/echo_target_page (etp_user, etp_event); diff --git a/db_patches/patch-add-echo_event-event_page_id.sql b/db_patches/patch-add-echo_event-event_page_id.sql deleted file mode 100644 index 3c4ae7142..000000000 --- a/db_patches/patch-add-echo_event-event_page_id.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE /*_*/echo_event ADD event_page_id int unsigned; diff --git a/db_patches/patch-alter-event_type-index.sql b/db_patches/patch-alter-event_type-index.sql deleted file mode 100644 index 2bfb2b0bf..000000000 --- a/db_patches/patch-alter-event_type-index.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP INDEX /*i*/event_type ON /*_*/echo_event; - -CREATE INDEX /*i*/echo_event_type ON /*_*/echo_event (event_type); diff --git a/db_patches/patch-alter-type_page-index.sql b/db_patches/patch-alter-type_page-index.sql deleted file mode 100644 index e43b4519b..000000000 --- a/db_patches/patch-alter-type_page-index.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP INDEX /*i*/type_page ON /*_*/echo_event; - -CREATE INDEX /*i*/event_type ON /*_*/echo_event (event_type); diff --git a/db_patches/patch-alter-user_timestamp-index.sql b/db_patches/patch-alter-user_timestamp-index.sql deleted file mode 100644 index e5710c4fb..000000000 --- a/db_patches/patch-alter-user_timestamp-index.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX /*i*/echo_user_timestamp ON /*_*/echo_notification (notification_user, notification_timestamp); -DROP INDEX /*i*/user_timestamp ON /*_*/echo_notification; diff --git a/db_patches/patch-drop-echo_subscription.sql b/db_patches/patch-drop-echo_subscription.sql deleted file mode 100644 index f04a4f0a2..000000000 --- a/db_patches/patch-drop-echo_subscription.sql +++ /dev/null @@ -1,2 +0,0 @@ --- drop this table because subscription is not supported -DROP TABLE /*_*/echo_subscription; diff --git a/db_patches/patch-email_batch-new-field.sql b/db_patches/patch-email_batch-new-field.sql deleted file mode 100644 index f25f913bc..000000000 --- a/db_patches/patch-email_batch-new-field.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE /*_*/echo_email_batch ADD COLUMN eeb_event_hash varchar(32) binary not null default ''; - -DROP INDEX /*i*/echo_email_batch_user_priority_event ON /*_*/echo_email_batch; - -CREATE INDEX /*i*/echo_email_batch_user_hash_priority ON /*_*/echo_email_batch (eeb_user_id, eeb_event_hash, eeb_event_priority); - - diff --git a/db_patches/patch-notification-bundling-field.sql b/db_patches/patch-notification-bundling-field.sql deleted file mode 100644 index f6d5938ef..000000000 --- a/db_patches/patch-notification-bundling-field.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE /*_*/echo_notification ADD COLUMN notification_bundle_base boolean not null default 1; -ALTER TABLE /*_*/echo_notification ADD COLUMN notification_bundle_hash varchar(32) binary not null default ''; -ALTER TABLE /*_*/echo_notification ADD COLUMN notification_bundle_display_hash varchar(32) binary not null default ''; - -CREATE INDEX /*i*/echo_notification_user_base_read_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_base, notification_read_timestamp); -CREATE INDEX /*i*/echo_notification_user_base_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_base, notification_timestamp, notification_event); -CREATE INDEX /*i*/echo_notification_user_hash_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_hash, notification_timestamp); -CREATE INDEX /*i*/echo_notification_user_hash_base_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_display_hash, notification_bundle_base, notification_timestamp); diff --git a/db_patches/sqlite/patch-event_agent-split.sqlite.sql b/db_patches/sqlite/patch-event_agent-split.sqlite.sql deleted file mode 100644 index 3650e86c2..000000000 --- a/db_patches/sqlite/patch-event_agent-split.sqlite.sql +++ /dev/null @@ -1,34 +0,0 @@ --- Split event_agent field to allow anonymous agents -ALTER TABLE echo_event ADD COLUMN event_agent_id int unsigned null; -ALTER TABLE echo_event ADD COLUMN event_agent_ip varchar binary null; -UPDATE echo_event SET event_agent_id = event_agent; - --- Rename current table to temporary name -ALTER TABLE /*_*/echo_event RENAME TO /*_*/temp_echo_event_split_event_agent; - --- Recreate table using the proper nullability constraint for event_variant -CREATE TABLE /*_*/echo_event ( - event_id int unsigned not null primary key auto_increment, - event_type varchar(64) binary not null, - event_variant varchar(64) binary null, - event_agent_id int unsigned null, -- The user who triggered it, if any - event_agent_ip varchar(39) binary null, -- IP address who triggered it, if any - event_page_title varchar(255) binary null, - event_extra BLOB NULL -) /*$wgDBTableOptions*/; - --- Copy over all the old data into the new table -INSERT INTO /*_*/echo_event - (event_id, event_type, event_variant, event_agent_id, event_page_title, event_extra) -SELECT - event_id, event_type, event_variant, event_agent, event_page_title, event_extra -FROM - /*_*/temp_echo_event_split_event_agent; - --- Drop the original table -DROP TABLE /*_*/temp_echo_event_split_event_agent; - --- recreate indexes -CREATE INDEX /*i*/echo_event_type ON /*_*/echo_event (event_type); - - diff --git a/db_patches/sqlite/patch-event_variant_nullability.sql b/db_patches/sqlite/patch-event_variant_nullability.sql deleted file mode 100644 index f5988f960..000000000 --- a/db_patches/sqlite/patch-event_variant_nullability.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Sqlites alter table statement can NOT change existing columns. The only --- option since we need to change the nullability of event_variant is to --- recreate the table and copy the data over. - --- Rename current table to temporary name -ALTER TABLE /*_*/echo_event RENAME TO /*_*/temp_echo_event_variant_nullability; - --- Recreate table using the proper nullability constraint for event_variant -CREATE TABLE /*_*/echo_event ( - event_id int unsigned not null primary key auto_increment, - event_type varchar(64) binary not null, - event_variant varchar(64) binary null, - event_agent_id int unsigned null, -- The user who triggered it, if any - event_agent_ip varchar(39) binary null, -- IP address who triggered it, if any - event_extra BLOB NULL, - event_page_id int unsigned null, - event_deleted tinyint unsigned not null default 0 -) /*$wgDBTableOptions*/; - --- Copy over all the old data into the new table -INSERT INTO /*_*/echo_event - (event_id, event_type, event_variant, event_agent_id, event_agent_ip, event_extra, event_page_id, event_deleted) -SELECT - event_id, event_type, event_variant, event_agent_id, event_agent_ip, event_extra, event_page_id, event_deleted -FROM - /*_*/temp_echo_event_variant_nullability; - --- Drop the original table -DROP TABLE /*_*/temp_echo_event_variant_nullability; - --- recreate indexes -CREATE INDEX /*i*/echo_event_type ON /*_*/echo_event (event_type); - diff --git a/db_patches/sqlite/patch-multiple_target_pages.sql b/db_patches/sqlite/patch-multiple_target_pages.sql deleted file mode 100644 index 0943bca2b..000000000 --- a/db_patches/sqlite/patch-multiple_target_pages.sql +++ /dev/null @@ -1,27 +0,0 @@ --- Sqlite can't add a primary key to an existing table - --- give current table temporary name -ALTER TABLE /*_*/echo_target_page RENAME TO /*_*/temp_echo_target_page; - --- recreate table with our new setup -CREATE TABLE /*_*/echo_target_page ( - etp_id int unsigned not null primary key auto_increment, - etp_user int unsigned not null default 0, - etp_page int unsigned not null default 0, - etp_event int unsigned not null default 0 -) /*$wgDBTableOptions*/; - --- copy over old data into new table -INSERT INTO /*_*/echo_target_page - (etp_user, etp_page, etp_event) -SELECT - etp_user, etp_page, etp_event -FROM - /*_*/temp_echo_target_page; - --- drop the original table -DROP TABLE /*_*/temp_echo_target_page; - --- recreate indexes -CREATE INDEX /*i*/echo_target_page_user_event ON /*_*/echo_target_page (etp_user, etp_event); -CREATE INDEX /*i*/echo_target_page_user_page_event ON /*_*/echo_target_page (etp_user, etp_page, etp_event); diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index 1ec908821..c832a44d1 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -156,62 +156,13 @@ class EchoHooks implements RecentChange_saveHook { $dbType = $updater->getDB()->getType(); $dir = dirname( __DIR__ ); - $baseSQLFile = "$dir/echo.sql"; - $updater->addExtensionTable( 'echo_event', $baseSQLFile ); + $updater->addExtensionTable( 'echo_event', "$dir/echo.sql" ); - $updater->addExtensionTable( 'echo_email_batch', "$dir/db_patches/echo_email_batch.sql" ); - $updater->addExtensionTable( 'echo_target_page', "$dir/db_patches/echo_target_page.sql" ); + // Added in REL1_28 + $updater->dropExtensionField( 'echo_target_page', 'etp_user', + "$dir/db_patches/{$dbType}/patch-drop-echo_target_page-etp_user.sql" ); - if ( $dbType === 'sqlite' ) { - $updater->modifyExtensionField( 'echo_event', 'event_agent', - "$dir/db_patches/sqlite/patch-event_agent-split.sql" ); - $updater->modifyExtensionField( 'echo_event', 'event_variant', - "$dir/db_patches/sqlite/patch-event_variant_nullability.sql" ); - $updater->addExtensionField( 'echo_target_page', 'etp_id', - "$dir/db_patches/sqlite/patch-multiple_target_pages.sql" ); - $updater->dropExtensionField( 'echo_target_page', 'etp_user', - "$dir/db_patches/sqlite/patch-drop-echo_target_page-etp_user.sql" ); - // There is no need to run the patch-event_extra-size or patch-event_agent_ip-size because - // sqlite ignores numeric arguments in parentheses that follow the type name (ex: VARCHAR(255)) - // see http://www.sqlite.org/datatype3.html Section 2.2 for more info - } else { - $updater->modifyExtensionField( 'echo_event', 'event_agent', - "$dir/db_patches/mysql/patch-event_agent-split.sql" ); - $updater->modifyExtensionField( 'echo_event', 'event_variant', - "$dir/db_patches/mysql/patch-event_variant_nullability.sql" ); - $updater->modifyExtensionField( 'echo_event', 'event_extra', - "$dir/db_patches/mysql/patch-event_extra-size.sql" ); - $updater->modifyExtensionField( 'echo_event', 'event_agent_ip', - "$dir/db_patches/mysql/patch-event_agent_ip-size.sql" ); - $updater->addExtensionField( 'echo_target_page', 'etp_id', - "$dir/db_patches/mysql/patch-multiple_target_pages.sql" ); - $updater->dropExtensionField( 'echo_target_page', 'etp_user', - "$dir/db_patches/mysql/patch-drop-echo_target_page-etp_user.sql" ); - } - - $updater->addExtensionField( 'echo_notification', 'notification_bundle_hash', - "$dir/db_patches/patch-notification-bundling-field.sql" ); - // This index was renamed twice, first from type_page to event_type and - // later from event_type to echo_event_type - if ( $updater->getDB()->indexExists( 'echo_event', 'type_page', __METHOD__ ) ) { - $updater->addExtensionIndex( 'echo_event', 'event_type', - "$dir/db_patches/patch-alter-type_page-index.sql" ); - } - $updater->dropExtensionTable( 'echo_subscription', - "$dir/db_patches/patch-drop-echo_subscription.sql" ); - if ( $dbType === 'mysql' ) { - $updater->dropExtensionField( 'echo_event', 'event_timestamp', - "$dir/db_patches/mysql/patch-drop-echo_event-event_timestamp.sql" ); - } - $updater->addExtensionField( 'echo_email_batch', 'eeb_event_hash', - "$dir/db_patches/patch-email_batch-new-field.sql" ); - $updater->addExtensionField( 'echo_event', 'event_page_id', - "$dir/db_patches/patch-add-echo_event-event_page_id.sql" ); - $updater->addExtensionIndex( 'echo_event', 'echo_event_type', - "$dir/db_patches/patch-alter-event_type-index.sql" ); - $updater->addExtensionIndex( 'echo_notification', 'echo_user_timestamp', - "$dir/db_patches/patch-alter-user_timestamp-index.sql" ); $updater->addExtensionIndex( 'echo_notification', 'echo_notification_event', "$dir/db_patches/patch-add-notification_event-index.sql" ); $updater->addPostDatabaseUpdateMaintenance( RemoveOrphanedEvents::class );