diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-19 23:19:35 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-24 14:51:34 +0200 |
commit | 00d483585bf7bdfced0c78f35603266c628d683a (patch) | |
tree | 0eb6385126c480b67fe05d11649a2d5b633b6016 /core | |
parent | f73f14207c6c0792396a2cab92ff33b806500867 (diff) | |
download | nextcloud-server-00d483585bf7bdfced0c78f35603266c628d683a.tar.gz nextcloud-server-00d483585bf7bdfced0c78f35603266c628d683a.zip |
fix: Add options to support all used features by core
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index dee9796a569..6c22557e3ff 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -91,7 +91,23 @@ class AddMissingIndices extends Command { $table = $schema->getTable($missingIndex['tableName']); if (!$table->hasIndex($missingIndex['indexName'])) { $output->writeln('<info>Adding additional ' . $missingIndex['indexName'] . ' index to the ' . $table->getName() . ' table, this can take some time...</info>'); - $table->addIndex($missingIndex['columns'], $missingIndex['indexName']); + + if ($missingIndex['dropUnnamedIndex']) { + foreach ($table->getIndexes() as $index) { + $columns = $index->getColumns(); + if ($columns === $missingIndex['columns']) { + $table->dropIndex($index->getName()); + } + } + } + + if ($missingIndex['uniqueIndex']) { + $table->addUniqueIndex($missingIndex['columns'], $missingIndex['indexName'], $missingIndex['options']); + } else { + $table->addIndex($missingIndex['columns'], $missingIndex['indexName'], [], $missingIndex['options']); + } + + $sqlQueries = $this->connection->migrateToSchema($schema->getWrappedSchema(), $dryRun); if ($dryRun && $sqlQueries !== null) { $output->writeln($sqlQueries); |