rdbms: Make adding a PK optional in DoctrineAbstractSchemaTrait.php

Bug: T268591
Change-Id: I08c24b6846006d7d92531b3868163c865465bee4
This commit is contained in:
Reedy 2020-11-24 03:14:40 +00:00
parent fb19c8b235
commit 02a1fc5937

View file

@ -32,6 +32,7 @@ trait DoctrineAbstractSchemaTrait {
foreach ( $schemaSpec['columns'] as $column ) {
$table->addColumn( $column['name'], $column['type'], $column['options'] );
}
foreach ( $schemaSpec['indexes'] as $index ) {
if ( $index['unique'] === true ) {
$table->addUniqueIndex( $index['columns'], $index['name'], $index['options'] ?? [] );
@ -39,7 +40,10 @@ trait DoctrineAbstractSchemaTrait {
$table->addIndex( $index['columns'], $index['name'], $index['flags'] ?? [], $index['options'] ?? [] );
}
}
$table->setPrimaryKey( $schemaSpec['pk'] );
if ( isset( $schemaSpec['pk'] ) ) {
$table->setPrimaryKey( $schemaSpec['pk'] );
}
if ( isset( $schemaSpec['options'] )
&& isset( $schemaSpec['options'][0]['table_options'] )