From a97c431d321a4ac2f92904fe2d7fefbc8964e499 Mon Sep 17 00:00:00 2001 From: deasraze Date: Thu, 29 Feb 2024 12:33:28 +0300 Subject: [PATCH] use empty unique index name if array key is numeric --- src/Tools/SchemaTool.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index c286c61126d..7cbb33fe9f1 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -337,8 +337,14 @@ public function getSchemaFromMetadata(array $classes): Schema if (isset($class->table['uniqueConstraints'])) { foreach ($class->table['uniqueConstraints'] as $indexName => $indexData) { - $uniqIndexName = is_numeric($indexName) ? null : $indexName; - $uniqIndex = new Index($uniqIndexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); + $uniqIndex = new Index( + is_numeric($indexName) ? '' : $indexName, + $this->getIndexColumns($class, $indexData), + true, + false, + [], + $indexData['options'] ?? [], + ); foreach ($table->getIndexes() as $tableIndexName => $tableIndex) { if ($tableIndex->isFulfilledBy($uniqIndex)) { @@ -347,7 +353,11 @@ public function getSchemaFromMetadata(array $classes): Schema } } - $table->addUniqueIndex($uniqIndex->getColumns(), $uniqIndexName, $indexData['options'] ?? []); + $table->addUniqueIndex( + $uniqIndex->getColumns(), + $uniqIndex->getName() === '' ? null : $uniqIndex->getName(), + $indexData['options'] ?? [], + ); } }