MediaWiki master
generateSchemaChangeSql.php
Go to the documentation of this file.
1<?php
2
26
27require_once __DIR__ . '/includes/SchemaMaintenance.php';
28
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( 'Build SQL files for schema changes from abstract JSON files' );
38 $this->scriptName = 'generateSchemaChangeSql.php';
39 }
40
41 protected function generateSchema( string $platform, array $schema ): string {
42 $schemaChangeBuilder = ( new DoctrineSchemaBuilderFactory() )->getSchemaChangeBuilder( $platform );
43
44 $schemaChangeSqls = $schemaChangeBuilder->getSchemaChangeSql( $schema );
45 if ( !$schemaChangeSqls ) {
46 $this->fatalError( 'No schema changes detected!' );
47 }
48
49 $sql = $this->cleanupSqlArray( $platform, $schemaChangeSqls );
50
51 return $sql;
52 }
53
54}
55
56$maintClass = GenerateSchemaChangeSql::class;
57require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script to generate schema from abstract json files.
__construct()
Default constructor.
generateSchema(string $platform, array $schema)
addDescription( $text)
Set the description text.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
cleanupSqlArray(string $platform, array $sqlArray)
Takes the output of DoctrineSchemaBuilder::getSql() or DoctrineSchemaChangeBuilder::getSchemaChangeSq...