22use Doctrine\DBAL\Platforms\AbstractPlatform;
23use Doctrine\DBAL\Schema\Schema;
32 private AbstractPlatform $platform;
34 private function addTableToSchema( Schema $schema, array $schemaSpec ) {
35 $prefix = $this->platform->getName() ===
'postgresql' ?
'' :
'/*_*/';
37 $table = $schema->createTable( $prefix . $schemaSpec[
'name'] );
38 foreach ( $schemaSpec[
'columns'] as $column ) {
39 $table->addColumn( $column[
'name'], $column[
'type'], $column[
'options'] );
42 foreach ( $schemaSpec[
'indexes'] as $index ) {
43 if ( $index[
'unique'] ===
true ) {
44 $table->addUniqueIndex( $index[
'columns'], $index[
'name'], $index[
'options'] ?? [] );
46 $table->addIndex( $index[
'columns'], $index[
'name'], $index[
'flags'] ?? [], $index[
'options'] ?? [] );
50 if ( isset( $schemaSpec[
'pk'] ) && $schemaSpec[
'pk'] !== [] ) {
51 $table->setPrimaryKey( $schemaSpec[
'pk'] );
54 if ( isset( $schemaSpec[
'table_options'] ) ) {
55 $table->addOption(
'table_options', implode(
' ', $schemaSpec[
'table_options'] ) );
57 $table->addOption(
'table_options',
'/*$wgDBTableOptions*/' );