mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Merge "Migrate and remove event_page_namespace and event_page_title"
This commit is contained in:
commit
69ca0fac71
4
echo.sql
4
echo.sql
|
@ -15,10 +15,6 @@ CREATE TABLE /*_*/echo_event (
|
|||
-- If the event doesn't have an agent, both fields are null.
|
||||
event_agent_id int unsigned null,
|
||||
event_agent_ip varchar(39) binary null,
|
||||
-- Unused, should be removed (T136427)
|
||||
event_page_namespace int unsigned null,
|
||||
-- Unused, should be removed (T136427)
|
||||
event_page_title varchar(255) binary null,
|
||||
-- JSON blob with additional information about the event
|
||||
event_extra BLOB NULL,
|
||||
-- Page ID of the page the event happened on, if any (key to page_id)
|
||||
|
|
|
@ -225,6 +225,14 @@ class EchoHooks {
|
|||
"$dir/db_patches/patch-add-event_page_id-index.sql" );
|
||||
$updater->dropExtensionIndex( 'echo_notification', 'user_event',
|
||||
"$dir/db_patches/patch-notification-pk.sql" );
|
||||
// Can't use addPostDatabaseUpdateMaintenance() here because that would
|
||||
// run the migration script after dropping the fields
|
||||
$updater->addExtensionUpdate( [ 'runMaintenance', 'UpdateEchoSchemaForSuppression',
|
||||
'extensions/Echo/maintenance/updateEchoSchemaForSuppression.php' ] );
|
||||
$updater->dropExtensionField( 'echo_event', 'event_page_namespace',
|
||||
"$dir/db_patches/patch-drop-echo_event-event_page_namespace.sql" );
|
||||
$updater->dropExtensionField( 'echo_event', 'event_page_title',
|
||||
"$dir/db_patches/patch-drop-echo_event-event_page_title.sql" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -444,8 +444,6 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
$row->event_agent_id = $user->getId();
|
||||
$row->event_agent_ip = null;
|
||||
$row->event_page_id = null;
|
||||
$row->event_page_namespace = null;
|
||||
$row->event_page_title = null;
|
||||
$row->event_extra = serialize( [
|
||||
'section' => $section ?: 'all',
|
||||
'wikis' => $wikis,
|
||||
|
|
|
@ -736,8 +736,6 @@ class EchoEvent extends EchoAbstractEntity implements Bundleable {
|
|||
'event_variant',
|
||||
'event_agent_id',
|
||||
'event_agent_ip',
|
||||
'event_page_namespace',
|
||||
'event_page_title',
|
||||
'event_extra',
|
||||
'event_page_id',
|
||||
'event_deleted',
|
||||
|
|
|
@ -39,7 +39,15 @@ class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance {
|
|||
public function doDBUpdates() {
|
||||
global $wgEchoCluster;
|
||||
|
||||
$reader = new BatchRowIterator( MWEchoDbFactory::getDB( DB_REPLICA ), $this->table, $this->idField, $this->mBatchSize );
|
||||
$dbr = MWEchoDbFactory::getDB( DB_REPLICA );
|
||||
$dbw = MWEchoDbFactory::getDB( DB_MASTER );
|
||||
|
||||
if ( !$dbw->fieldExists( 'echo_event', 'event_page_title' ) ) {
|
||||
$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->mBatchSize );
|
||||
$reader->addConditions( [
|
||||
"event_page_title IS NOT NULL",
|
||||
"event_page_id" => null,
|
||||
|
@ -48,7 +56,7 @@ class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance {
|
|||
|
||||
$updater = new BatchRowUpdate(
|
||||
$reader,
|
||||
new BatchRowWriter( MWEchoDbFactory::getDB( DB_MASTER ), $this->table, $wgEchoCluster ),
|
||||
new BatchRowWriter( $dbw, $this->table, $wgEchoCluster ),
|
||||
new EchoSuppressionRowUpdateGenerator
|
||||
);
|
||||
$updater->setOutput( function ( $text ) {
|
||||
|
|
Loading…
Reference in a new issue