2 namespace MediaWiki\Tests\Storage
;
4 use Wikimedia\Rdbms\IMaintainableDatabase
;
5 use MediaWiki\DB\PatchFileLocation
;
8 * Trait providing schema overrides that allow tests to run against the intermediate MCR database
9 * schema for use during schema migration.
11 trait McrWriteBothSchemaOverride
{
13 use PatchFileLocation
;
14 use McrSchemaDetection
;
19 protected function getMcrMigrationStage() {
20 return SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
;
26 protected function getMcrTablesToReset() {
27 return [ 'content', 'content_models', 'slots', 'slot_roles' ];
33 protected function getSchemaOverrides( IMaintainableDatabase
$db ) {
41 if ( !$this->hasMcrTables( $db ) ) {
42 $overrides['create'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
43 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slot_roles' );
44 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content_models' );
45 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content' );
46 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slots' );
49 if ( !$this->hasPreMcrFields( $db ) ) {
50 $overrides['alter'][] = 'revision';
51 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'create-pre-mcr-fields', __DIR__
);