MediaWiki master
generateSchemaSql.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 from abstract JSON files' );
38 $this->scriptName = 'generateSchemaSql.php';
39 }
40
41 protected function generateSchema( string $platform, array $schema ): string {
42 $schemaBuilder = ( new DoctrineSchemaBuilderFactory() )->getSchemaBuilder( $platform );
43
44 foreach ( $schema as $table ) {
45 $schemaBuilder->addTable( $table );
46 }
47 $tableSqls = $schemaBuilder->getSql();
48
49 $sql = $this->cleanupSqlArray( $platform, $tableSqls );
50
51 return $sql;
52 }
53
54}
55
56$maintClass = GenerateSchemaSql::class;
57require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script to generate schema from abstract json files.
generateSchema(string $platform, array $schema)
__construct()
Default constructor.
addDescription( $text)
Set the description text.
cleanupSqlArray(string $platform, array $sqlArray)
Takes the output of DoctrineSchemaBuilder::getSql() or DoctrineSchemaChangeBuilder::getSchemaChangeSq...