Wire empty abstract schema into installer
For more information on schema changes see: https://www.mediawiki.org/wiki/Manual:Schema_changes Bug: T191231 Bug: T230428 Change-Id: I779b9c61e388e998738a2ed41b0b8e2afdecd232
This commit is contained in:
parent
a69d817523
commit
11f241589b
12 changed files with 61 additions and 10 deletions
|
|
@ -243,12 +243,22 @@ abstract class DatabaseInstaller {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create database tables from scratch.
|
||||
* Create database tables from scratch from the automatically generated file
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function createTables() {
|
||||
return $this->stepApplySourceFile( 'getSchemaPath', 'install', true );
|
||||
return $this->stepApplySourceFile( 'getGeneratedSchemaPath', 'install', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create database tables from scratch.
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function createManualTables() {
|
||||
// TODO: Set "archiveTableMustNotExist" to "false" when archive table is migrated to tables.json
|
||||
return $this->stepApplySourceFile( 'getSchemaPath', 'install-manual', true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -290,6 +300,16 @@ abstract class DatabaseInstaller {
|
|||
return $this->getSqlFilePath( $db, 'tables.sql' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a path to the DBMS-specific automatically generated schema file.
|
||||
*
|
||||
* @param IDatabase $db
|
||||
* @return string
|
||||
*/
|
||||
public function getGeneratedSchemaPath( $db ) {
|
||||
return $this->getSqlFilePath( $db, 'tables-generated.sql' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a path to the DBMS-specific update key file,
|
||||
* otherwise default to update-keys.sql
|
||||
|
|
|
|||
|
|
@ -1551,6 +1551,7 @@ abstract class Installer {
|
|||
$coreInstallSteps = [
|
||||
[ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
|
||||
[ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
|
||||
[ 'name' => 'tables-manual', 'callback' => [ $installer, 'createManualTables' ] ],
|
||||
[ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
|
||||
[ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
|
||||
[ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
|
||||
|
|
|
|||
|
|
@ -624,9 +624,16 @@ class PostgresInstaller extends DatabaseInstaller {
|
|||
if ( $error !== true ) {
|
||||
$conn->reportQueryError( $error, 0, '', __METHOD__ );
|
||||
$conn->rollback( __METHOD__ );
|
||||
$status->fatal( 'config-install-tables-failed', $error );
|
||||
$status->fatal( 'config-install-tables-manual-failed', $error );
|
||||
} else {
|
||||
$conn->commit( __METHOD__ );
|
||||
$error = $conn->sourceFile( $this->getGeneratedSchemaPath( $conn ) );
|
||||
if ( $error !== true ) {
|
||||
$conn->reportQueryError( $error, 0, '', __METHOD__ );
|
||||
$conn->rollback( __METHOD__ );
|
||||
$status->fatal( 'config-install-tables-failed', $error );
|
||||
} else {
|
||||
$conn->commit( __METHOD__ );
|
||||
}
|
||||
}
|
||||
// Resume normal operations
|
||||
if ( $status->isOK() ) {
|
||||
|
|
|
|||
|
|
@ -335,6 +335,9 @@ EOT;
|
|||
*/
|
||||
public function createTables() {
|
||||
$status = parent::createTables();
|
||||
if ( $status->isGood() ) {
|
||||
$status = parent::createManualTables();
|
||||
}
|
||||
|
||||
return $this->setupSearchIndex( $status );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,9 +259,12 @@
|
|||
"config-install-user-missing": "The specified user \"$1\" does not exist.",
|
||||
"config-install-user-missing-create": "The specified user \"$1\" does not exist.\nPlease click the \"create account\" checkbox below if you want to create it.",
|
||||
"config-install-restore-services": "Restoring mediawiki services",
|
||||
"config-install-tables": "Creating tables",
|
||||
"config-install-tables": "Creating tables, step one",
|
||||
"config-install-tables-exist": "<strong>Warning:</strong> MediaWiki tables seem to already exist.\nSkipping creation.",
|
||||
"config-install-tables-failed": "<strong>Error:</strong> Table creation failed with the following error: $1",
|
||||
"config-install-tables-manual": "Creating tables, step two",
|
||||
"config-install-tables-manual-exist": "<strong>Warning:</strong> MediaWiki tables seem to already exist.\nSkipping creation.",
|
||||
"config-install-tables-manual-failed": "<strong>Error:</strong> Table creation failed with the following error: $1",
|
||||
"config-install-interwiki": "Populating default interwiki table",
|
||||
"config-install-interwiki-list": "Could not read file <code>interwiki.list</code>.",
|
||||
"config-install-interwiki-exists": "<strong>Warning:</strong> The interwiki table seems to already have entries.\nSkipping default list.",
|
||||
|
|
|
|||
|
|
@ -283,9 +283,12 @@
|
|||
"config-install-user-missing": "Used as PostgreSQL error message. Parameters:\n* $1 - database username\nSee also:\n* {{msg-mw|Config-install-user-missing-create}}",
|
||||
"config-install-user-missing-create": "Used as PostgreSQL error message. Parameters:\n* $1 - database username\nSee also:\n* {{msg-mw|Config-install-user-missing}}",
|
||||
"config-install-restore-services": "Message indicates that MediaWiki services overridden during installation are being restored",
|
||||
"config-install-tables": "Message indicates that the tables are being created\n\nSee also:\n*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-updates}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
|
||||
"config-install-tables": "Message indicates that some of the tables are being created\n\nSee also:\n*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-updates}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
|
||||
"config-install-tables-exist": "Error notice during the installation saying that the database already seems set up for MediaWiki, so it's continuing without taking that step.",
|
||||
"config-install-tables-failed": "Used as PostgreSQL error message. Parameters:\n* $1 - detailed error message",
|
||||
"config-install-tables-manual": "Message indicates that rest of the tables are being created",
|
||||
"config-install-tables-manual-exist": "Error notice during the installation saying that the database already seems set up for MediaWiki, so it's continuing without taking that step.",
|
||||
"config-install-tables-manual-failed": "Used as PostgreSQL error message. Parameters:\n* $1 - detailed error message",
|
||||
"config-install-interwiki": "Message indicates that the interwikitables are being populated\n\nSee also:\n*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
|
||||
"config-install-interwiki-list": "{{doc-important|Do not translate <code>interwiki.list</code>.}}\nUsed as error message.",
|
||||
"config-install-interwiki-exists": "Error notice during the installation saying that one of the database tables is already set up, so it's continuing without taking that step.",
|
||||
|
|
|
|||
|
|
@ -72,11 +72,14 @@ class GenerateSchemaSql extends Maintenance {
|
|||
"-- Do not modify this file directly.\n" .
|
||||
"-- See https://www.mediawiki.org/wiki/Manual:Schema_changes\n";
|
||||
|
||||
$schema = $sql . implode( ";\n\n", $schemaBuilder->getSql() ) . ';';
|
||||
$tables = $schemaBuilder->getSql();
|
||||
if ( $tables !== [] ) {
|
||||
// Temporary
|
||||
$sql = $sql . implode( ";\n\n", $tables ) . ';';
|
||||
$sql = ( new SqlFormatter( new NullHighlighter() ) )->format( $sql );
|
||||
}
|
||||
|
||||
$formattedSchema = ( new SqlFormatter( new NullHighlighter() ) )->format( $schema );
|
||||
|
||||
file_put_contents( $sqlFile, $formattedSchema );
|
||||
file_put_contents( $sqlFile, $sql );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
3
maintenance/postgres/tables-generated.sql
Normal file
3
maintenance/postgres/tables-generated.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
3
maintenance/sqlite/tables-generated.sql
Normal file
3
maintenance/sqlite/tables-generated.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
3
maintenance/tables-generated.sql
Normal file
3
maintenance/tables-generated.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
1
maintenance/tables.json
Normal file
1
maintenance/tables.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -362,6 +362,7 @@ class DatabaseSqliteTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$currentDB = DatabaseSqlite::newStandaloneInstance( ':memory:' );
|
||||
$currentDB->sourceFile( "$IP/maintenance/tables.sql" );
|
||||
$currentDB->sourceFile( "$IP/maintenance/sqlite/tables-generated.sql" );
|
||||
|
||||
$currentTables = $this->getTables( $currentDB );
|
||||
sort( $currentTables );
|
||||
|
|
|
|||
Loading…
Reference in a new issue