mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 09:10:12 +00:00
Drop schema updates from MW 1.33 and 1.34
Change-Id: I9515984e294cd3910a841a07eb3239fa20040a3e
This commit is contained in:
parent
36cf0becf0
commit
0bc5808783
|
@ -1057,7 +1057,6 @@
|
||||||
"RecomputeNotifCounts": "maintenance/recomputeNotifCounts.php",
|
"RecomputeNotifCounts": "maintenance/recomputeNotifCounts.php",
|
||||||
"RemoveInvalidNotification": "maintenance/removeInvalidNotification.php",
|
"RemoveInvalidNotification": "maintenance/removeInvalidNotification.php",
|
||||||
"RemoveOrphanedEvents": "maintenance/removeOrphanedEvents.php",
|
"RemoveOrphanedEvents": "maintenance/removeOrphanedEvents.php",
|
||||||
"UpdateEchoSchemaForSuppression": "maintenance/updateEchoSchemaForSuppression.php",
|
|
||||||
"EchoUpdatePerUserBlacklist": "maintenance/updatePerUserBlacklist.php",
|
"EchoUpdatePerUserBlacklist": "maintenance/updatePerUserBlacklist.php",
|
||||||
"EchoPush\\PushNotifier": "includes/Push/PushNotifier.php",
|
"EchoPush\\PushNotifier": "includes/Push/PushNotifier.php",
|
||||||
"MediaWiki\\Extension\\Notifications\\Push\\PushNotifier": "includes/Push/PushNotifier.php"
|
"MediaWiki\\Extension\\Notifications\\Push\\PushNotifier": "includes/Push/PushNotifier.php"
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace MediaWiki\Extension\Notifications;
|
||||||
|
|
||||||
use DatabaseUpdater;
|
use DatabaseUpdater;
|
||||||
use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
|
use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
|
||||||
use UpdateEchoSchemaForSuppression;
|
|
||||||
|
|
||||||
class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
|
class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
|
||||||
|
|
||||||
|
@ -25,24 +24,6 @@ class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
|
||||||
|
|
||||||
$updater->addExtensionTable( 'echo_event', "$dir/$dbType/tables-generated.sql" );
|
$updater->addExtensionTable( 'echo_event', "$dir/$dbType/tables-generated.sql" );
|
||||||
|
|
||||||
// 1.33
|
|
||||||
// Can't use addPostDatabaseUpdateMaintenance() here because that would
|
|
||||||
// run the migration script after dropping the fields
|
|
||||||
$updater->addExtensionUpdate( [ 'runMaintenance', UpdateEchoSchemaForSuppression::class,
|
|
||||||
'extensions/Echo/maintenance/updateEchoSchemaForSuppression.php' ] );
|
|
||||||
$updater->dropExtensionField( 'echo_event', 'event_page_namespace',
|
|
||||||
"$dir/patch-drop-echo_event-event_page_namespace.sql" );
|
|
||||||
$updater->dropExtensionField( 'echo_event', 'event_page_title',
|
|
||||||
"$dir/patch-drop-echo_event-event_page_title.sql" );
|
|
||||||
if ( $dbType === 'mysql' ) {
|
|
||||||
$updater->dropExtensionField( 'echo_notification', 'notification_bundle_base',
|
|
||||||
"$dir/mysql/patch-drop-notification_bundle_base.sql" );
|
|
||||||
$updater->dropExtensionField( 'echo_notification', 'notification_bundle_display_hash',
|
|
||||||
"$dir/mysql/patch-drop-notification_bundle_display_hash.sql" );
|
|
||||||
}
|
|
||||||
$updater->dropExtensionIndex( 'echo_notification', 'echo_notification_user_hash_timestamp',
|
|
||||||
"$dir/patch-drop-user-hash-timestamp-index.sql" );
|
|
||||||
|
|
||||||
// 1.35
|
// 1.35
|
||||||
$updater->addExtensionTable( 'echo_push_provider', "$dir/echo_push_provider.sql" );
|
$updater->addExtensionTable( 'echo_push_provider', "$dir/echo_push_provider.sql" );
|
||||||
$updater->addExtensionTable( 'echo_push_subscription', "$dir/echo_push_subscription.sql" );
|
$updater->addExtensionTable( 'echo_push_subscription', "$dir/echo_push_subscription.sql" );
|
||||||
|
@ -52,7 +33,7 @@ class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
|
||||||
|
|
||||||
// 1.39
|
// 1.39
|
||||||
if ( $dbType === 'mysql' && $db->tableExists( 'echo_push_subscription', __METHOD__ ) ) {
|
if ( $dbType === 'mysql' && $db->tableExists( 'echo_push_subscription', __METHOD__ ) ) {
|
||||||
// Splitted into single steps to support updates from some releases as well - T322143
|
// Split into single steps to support updates from some releases as well - T322143
|
||||||
$updater->renameExtensionIndex(
|
$updater->renameExtensionIndex(
|
||||||
'echo_push_subscription',
|
'echo_push_subscription',
|
||||||
'echo_push_subscription_user_id',
|
'echo_push_subscription_user_id',
|
||||||
|
@ -99,16 +80,10 @@ class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
|
||||||
|
|
||||||
global $wgEchoSharedTrackingCluster, $wgEchoSharedTrackingDB;
|
global $wgEchoSharedTrackingCluster, $wgEchoSharedTrackingDB;
|
||||||
// Following tables should only be created if both cluster and database are false.
|
// Following tables should only be created if both cluster and database are false.
|
||||||
// Otherwise they are not created in the place they are accesses, because
|
// Otherwise, they are not created in the place they are accesses, because
|
||||||
// DatabaseUpdater does not support other databases other than main wiki schema.
|
// DatabaseUpdater does not support other databases other than the main wiki schema.
|
||||||
if ( $wgEchoSharedTrackingCluster === false && $wgEchoSharedTrackingDB === false ) {
|
if ( $wgEchoSharedTrackingCluster === false && $wgEchoSharedTrackingDB === false ) {
|
||||||
$updater->addExtensionTable( 'echo_unread_wikis', "$dir/$dbType/tables-sharedtracking-generated.sql" );
|
$updater->addExtensionTable( 'echo_unread_wikis', "$dir/$dbType/tables-sharedtracking-generated.sql" );
|
||||||
|
|
||||||
// 1.34 (backported) - not for sqlite, the used data type supports the new length
|
|
||||||
if ( $updater->getDB()->getType() === 'mysql' ) {
|
|
||||||
$updater->modifyExtensionField( 'echo_unread_wikis', 'euw_wiki',
|
|
||||||
"$dir/mysql/patch-increase-varchar-echo_unread_wikis-euw_wiki.sql" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Update event_page_id in echo_event based on event_page_title and
|
|
||||||
* event_page_namespace
|
|
||||||
*
|
|
||||||
* @ingroup Maintenance
|
|
||||||
*/
|
|
||||||
|
|
||||||
use MediaWiki\Extension\Notifications\DbFactory;
|
|
||||||
use MediaWiki\Extension\Notifications\SuppressionRowUpdateGenerator;
|
|
||||||
|
|
||||||
require_once getenv( 'MW_INSTALL_PATH' ) !== false
|
|
||||||
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
|
||||||
: __DIR__ . '/../../../maintenance/Maintenance.php';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maintenance script that populates the event_page_id column of echo_event
|
|
||||||
*
|
|
||||||
* @ingroup Maintenance
|
|
||||||
*/
|
|
||||||
class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string The table to update
|
|
||||||
*/
|
|
||||||
protected $table = 'echo_event';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string The primary key column of the table to update
|
|
||||||
*/
|
|
||||||
protected $idField = 'event_id';
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
$this->setBatchSize( 500 );
|
|
||||||
$this->requireExtension( 'Echo' );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdateKey() {
|
|
||||||
return __CLASS__;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doDBUpdates() {
|
|
||||||
global $wgEchoCluster;
|
|
||||||
$lbFactory = DbFactory::newFromDefault();
|
|
||||||
|
|
||||||
$dbr = $lbFactory->getEchoDb( DB_REPLICA );
|
|
||||||
$dbw = $lbFactory->getEchoDb( DB_PRIMARY );
|
|
||||||
'@phan-var \Wikimedia\Rdbms\IMaintainableDatabase $dbw';
|
|
||||||
|
|
||||||
if ( !$dbw->fieldExists( 'echo_event', 'event_page_title', __METHOD__ ) ) {
|
|
||||||
$this->output( "No event_page_title field, skipping migration from event_page_title to event_page_id\n" );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$reader = new BatchRowIterator( $dbr, $this->table, $this->idField, $this->getBatchSize() );
|
|
||||||
$reader->addConditions( [
|
|
||||||
"event_page_title IS NOT NULL",
|
|
||||||
"event_page_id" => null,
|
|
||||||
] );
|
|
||||||
$reader->setFetchColumns( [ 'event_page_namespace', 'event_page_title', 'event_extra', 'event_type' ] );
|
|
||||||
$reader->setCaller( __METHOD__ );
|
|
||||||
|
|
||||||
$writer = new BatchRowWriter( $dbw, $this->table, $wgEchoCluster );
|
|
||||||
$writer->setCaller( __METHOD__ );
|
|
||||||
|
|
||||||
$updater = new BatchRowUpdate(
|
|
||||||
$reader,
|
|
||||||
$writer,
|
|
||||||
new SuppressionRowUpdateGenerator
|
|
||||||
);
|
|
||||||
$updater->setOutput( function ( $text ) {
|
|
||||||
$this->output( $text );
|
|
||||||
} );
|
|
||||||
$updater->execute();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$maintClass = UpdateEchoSchemaForSuppression::class;
|
|
||||||
require_once RUN_MAINTENANCE_IF_MAIN;
|
|
|
@ -1,5 +0,0 @@
|
||||||
-- Drop unused field notification_bundle_base and the indexes that contain it
|
|
||||||
DROP INDEX /*i*/echo_notification_user_base_read_timestamp ON /*_*/echo_notification;
|
|
||||||
DROP INDEX /*i*/echo_notification_user_base_timestamp ON /*_*/echo_notification;
|
|
||||||
DROP INDEX /*i*/echo_notification_user_hash_base_timestamp ON /*_*/echo_notification;
|
|
||||||
ALTER TABLE /*_*/echo_notification DROP notification_bundle_base;
|
|
|
@ -1,2 +0,0 @@
|
||||||
-- Drop unused field notification_bundle_display_hash
|
|
||||||
ALTER TABLE /*_*/echo_notification DROP notification_bundle_display_hash;
|
|
|
@ -1,2 +0,0 @@
|
||||||
-- Increase varchar size to 64
|
|
||||||
ALTER TABLE /*_*/echo_unread_wikis MODIFY euw_wiki VARCHAR(64) NOT NULL;
|
|
|
@ -1,3 +0,0 @@
|
||||||
-- Patch to drop unused event_page_namespace
|
|
||||||
alter table /*_*/echo_event drop event_page_namespace;
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
-- Patch to drop unused event_page_title
|
|
||||||
alter table /*_*/echo_event drop event_page_title;
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
-- Drop unused index echo_notification_user_hash_timestamp
|
|
||||||
DROP INDEX /*i*/echo_notification_user_hash_timestamp ON /*_*/echo_notification;
|
|
Loading…
Reference in a new issue