During development a lot of classes were placed in MediaWiki\Storage\. The precedent set would mean that every class relating to something stored in a database table, plus all related value classes and such, would go into that namespace. Let's put them into MediaWiki\Revision\ instead. Then future classes related to the 'page' table can go into MediaWiki\Page\, future classes related to the 'user' table can go into MediaWiki\User\, and so on. Note I didn't move DerivedPageDataUpdater, PageUpdateException, PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\ instead. Bug: T204158 Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
namespace MediaWiki\Tests\Revision;
|
|
|
|
use Wikimedia\Rdbms\IMaintainableDatabase;
|
|
use MediaWiki\DB\PatchFileLocation;
|
|
|
|
/**
|
|
* Trait providing schema overrides that allow tests to run against the post-migration
|
|
* MCR database schema.
|
|
*/
|
|
trait McrSchemaOverride {
|
|
|
|
use PatchFileLocation;
|
|
use McrSchemaDetection;
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
protected function getMcrMigrationStage() {
|
|
return MIGRATION_NEW;
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
protected function getMcrTablesToReset() {
|
|
return [
|
|
'content',
|
|
'content_models',
|
|
'slots',
|
|
'slot_roles',
|
|
];
|
|
}
|
|
|
|
protected function getSchemaOverrides( IMaintainableDatabase $db ) {
|
|
$overrides = [
|
|
'scripts' => [],
|
|
'drop' => [],
|
|
'create' => [],
|
|
'alter' => [],
|
|
];
|
|
|
|
if ( !$this->hasMcrTables( $db ) ) {
|
|
$overrides['create'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slot_roles' );
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content_models' );
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content' );
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slots.sql' );
|
|
}
|
|
|
|
if ( !$this->hasPreMcrFields( $db ) ) {
|
|
$overrides['alter'][] = 'revision';
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'drop-pre-mcr-fields', __DIR__ );
|
|
}
|
|
|
|
return $overrides;
|
|
}
|
|
|
|
}
|