8use Doctrine\DBAL\Platforms\AbstractPlatform;
9use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
10use Doctrine\DBAL\Schema\Schema;
19 private AbstractPlatform $platform;
21 private function addTableToSchema( Schema $schema, array $schemaSpec ): Schema {
22 $prefix = ( $this->platform instanceof PostgreSQLPlatform ) ?
'' :
'/*_*/';
24 $table = $schema->createTable( $prefix . $schemaSpec[
'name'] );
25 foreach ( $schemaSpec[
'columns'] as $column ) {
26 $table->addColumn( $column[
'name'], $column[
'type'], $column[
'options'] );
29 foreach ( $schemaSpec[
'indexes'] as $index ) {
30 if ( $index[
'unique'] ===
true ) {
31 $table->addUniqueIndex( $index[
'columns'], $index[
'name'], $index[
'options'] ?? [] );
33 $table->addIndex( $index[
'columns'], $index[
'name'], $index[
'flags'] ?? [], $index[
'options'] ?? [] );
37 if ( isset( $schemaSpec[
'pk'] ) && $schemaSpec[
'pk'] !== [] ) {
38 $table->setPrimaryKey( $schemaSpec[
'pk'] );
41 if ( isset( $schemaSpec[
'table_options'] ) ) {
42 $table->addOption(
'table_options', implode(
' ', $schemaSpec[
'table_options'] ) );
44 $table->addOption(
'table_options',
'/*$wgDBTableOptions*/' );