diff --git a/lib/Command/Db/CreateIndices.php b/lib/Command/Db/CreateIndices.php index ed9ce69d87..c781664a58 100644 --- a/lib/Command/Db/CreateIndices.php +++ b/lib/Command/Db/CreateIndices.php @@ -40,10 +40,16 @@ protected function runCommands(): int { $this->addForeignKeyConstraints(); $this->addUniqueIndices(); $this->connection->migrateToSchema($this->schema); + $this->listExistingIndices(); return 0; } + private function listExistingIndices(): void { + $this->printComment('Existing indices:'); + $messages = $this->indexManager->listExistingIndices(); + $this->printInfo($messages, ' - '); + } /** * add an on delete fk contraint to all tables referencing the main polls table */ diff --git a/lib/Db/V3/IndexManager.php b/lib/Db/V3/IndexManager.php index 34e9e7aafd..21f6cce73b 100644 --- a/lib/Db/V3/IndexManager.php +++ b/lib/Db/V3/IndexManager.php @@ -104,6 +104,24 @@ public function createForeignKeyConstraint(string $parentTableName, string $chil return 'Added ' . $parentTableName . '[' . $constraintColumn . '] <- ' . $childTableName . '[id]'; } + public function listExistingIndices() { + $this->needsSchema(); + $messages = []; + + foreach (array_keys(TableSchema::TABLES) as $tableName) { + $tableName = $this->getTableName($tableName); + + if ($this->schema->hasTable($tableName)) { + $table = $this->schema->getTable($tableName); + + foreach ($table->getIndexes() as $index) { + $messages[] = $tableName . ' - ' . $index->getName() . ' (' . implode(',', $index->getColumns()) . ')'; + } + } + } + return $messages; + } + /** * Create one named index for table * diff --git a/lib/Migration/V3/TableSchema.php b/lib/Migration/V3/TableSchema.php index 454b2049e2..d4cdaffd4b 100644 --- a/lib/Migration/V3/TableSchema.php +++ b/lib/Migration/V3/TableSchema.php @@ -67,9 +67,6 @@ abstract class TableSchema { 'polls_polls_deleted' => ['columns' => ['deleted']], 'polls_polls_owners' => ['columns' => ['owner']], ], - PollGroup::RELATION_TABLE => [ - 'polls_groups_polls' => ['columns' => ['poll_id', 'group_id']], - ], Option::TABLE => [ 'polls_options' => ['columns' => ['poll_id', 'deleted']], 'polls_options_hash' => ['columns' => ['poll_id', 'poll_option_hash', 'deleted']],