Enable inserts to the new MCR db schema in single slot mode only. TODO: - RELEASE NOTES Notes: - When in MIGRATION_WRITE_NEW or greater, deleting and then restoring a page will result in different data in the revision table. For example, if you delete a page that has text_ids present in the revision table and restore it, the text_ids will be blank after. - When in MIGRATION_WRITE_BOTH or greater the archive table will start to ar_content_model entries where previously it would have been given NULL. This is due to the old content schema having NULL in the db when the default content model is used, but the new schema will always have a value, taken from the content_models table Note: If259b1e1c49ce was squashed into this change. Bug: T183488 Bug: T174024 Change-Id: Ic2221da30c8f6ac2ba42720fcd568f2d0ed70534
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
namespace MediaWiki\Tests\Storage;
|
|
|
|
use Wikimedia\Rdbms\IMaintainableDatabase;
|
|
use MediaWiki\DB\PatchFileLocation;
|
|
|
|
/**
|
|
* Trait providing schema overrides that allow tests to run against the intermediate MCR database
|
|
* schema for use during schema migration.
|
|
*/
|
|
trait McrWriteBothSchemaOverride {
|
|
|
|
use PatchFileLocation;
|
|
use McrSchemaDetection;
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
protected function getMcrMigrationStage() {
|
|
return MIGRATION_WRITE_BOTH;
|
|
}
|
|
|
|
/**
|
|
* @return string[]
|
|
*/
|
|
protected function getMcrTablesToReset() {
|
|
return [ 'content', 'content_models', 'slots', 'slot_roles' ];
|
|
}
|
|
|
|
/**
|
|
* @override MediaWikiTestCase::getSchemaOverrides
|
|
* @return array[]
|
|
*/
|
|
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' );
|
|
}
|
|
|
|
if ( !$this->hasPreMcrFields( $db ) ) {
|
|
$overrides['alter'][] = 'revision';
|
|
$overrides['scripts'][] = $this->getSqlPatchPath( $db, 'create-pre-mcr-fields', __DIR__ );
|
|
}
|
|
|
|
return $overrides;
|
|
}
|
|
|
|
}
|