mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-11 17:00:10 +00:00
Drop DB patches from pre MW 1.26
Change-Id: I6693239455a2696b7bb77841041204b75a3c99fb
This commit is contained in:
parent
532faf27f5
commit
5d4a012d48
|
@ -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);
|
|
@ -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);
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE /*_*/echo_event DROP event_timestamp;
|
|
@ -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;
|
|
@ -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;
|
|
@ -1,2 +0,0 @@
|
|||
-- Patch to add extra space to event_extra
|
||||
alter table /*_*/echo_event change column event_extra event_extra BLOB NULL;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE /*_*/echo_event CHANGE COLUMN event_variant event_variant varchar(64) binary 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);
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE /*_*/echo_event ADD event_page_id int unsigned;
|
|
@ -1,3 +0,0 @@
|
|||
DROP INDEX /*i*/event_type ON /*_*/echo_event;
|
||||
|
||||
CREATE INDEX /*i*/echo_event_type ON /*_*/echo_event (event_type);
|
|
@ -1,3 +0,0 @@
|
|||
DROP INDEX /*i*/type_page ON /*_*/echo_event;
|
||||
|
||||
CREATE INDEX /*i*/event_type ON /*_*/echo_event (event_type);
|
|
@ -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;
|
|
@ -1,2 +0,0 @@
|
|||
-- drop this table because subscription is not supported
|
||||
DROP TABLE /*_*/echo_subscription;
|
|
@ -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);
|
||||
|
||||
|
|
@ -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);
|
|
@ -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);
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
@ -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);
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue