More work on formatting generated sql

Bug: T230428
Change-Id: I2cb4cab045addd8f532f414923ce323e1bed52f2
This commit is contained in:
Amir Sarabadani 2020-05-10 03:22:24 +02:00
parent 60bace4d37
commit 8d011de416
4 changed files with 18 additions and 0 deletions

View file

@ -69,6 +69,7 @@ class GenerateSchemaSql extends Maintenance {
$schemaBuilder->addTable( $table );
}
$sql = "-- This file is automatically generated using maintenance/generateSchemaSql.php.\n" .
"-- Source: $jsonFile\n" .
"-- Do not modify this file directly.\n" .
"-- See https://www.mediawiki.org/wiki/Manual:Schema_changes\n";
@ -78,6 +79,20 @@ class GenerateSchemaSql extends Maintenance {
$sql = $sql . implode( ";\n\n", $tables ) . ';';
$sql = ( new SqlFormatter( new NullHighlighter() ) )->format( $sql );
}
// Until the linting issue is resolved
// https://github.com/doctrine/sql-formatter/issues/53
$sql = str_replace( "\n/*_*/\n", " /*_*/", $sql );
$sql = str_replace( "; CREATE ", ";\nCREATE ", $sql );
$sql = str_replace(
"\n" . '/*$wgDBTableOptions*/' . ";",
' /*$wgDBTableOptions*/;' . "\n",
$sql
);
$sql = str_replace(
"\n" . '/*$wgDBTableOptions*/' . "\n;",
' /*$wgDBTableOptions*/;' . "\n",
$sql
);
file_put_contents( $sqlFile, $sql );
}

View file

@ -1,3 +1,4 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: maintenance/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes

View file

@ -1,3 +1,4 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: maintenance/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes

View file

@ -1,3 +1,4 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: maintenance/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes