diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-19 23:01:13 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-24 14:51:32 +0200 |
commit | bd0a149a4ffa2a2e398dddb99f4b0d486bfc2cb7 (patch) | |
tree | ad57496af8065803a6d7c6a74db323d38eb8e99b /apps | |
parent | 2eded24eff5f3f0c911ffbd5841178030c8f9363 (diff) | |
download | nextcloud-server-bd0a149a4ffa2a2e398dddb99f4b0d486bfc2cb7.tar.gz nextcloud-server-bd0a149a4ffa2a2e398dddb99f4b0d486bfc2cb7.zip |
feat(dispatcher): Add typed event for "db:add-missing-primary-keys"
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Controller/CheckSetupController.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 170c6a3870a..5d7989f0256 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -76,6 +76,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\DB\Events\AddMissingColumnsEvent; use OCP\DB\Events\AddMissingIndicesEvent; +use OCP\DB\Events\AddMissingPrimaryKeyEvent; use OCP\DB\Types; use OCP\EventDispatcher\IEventDispatcher; use OCP\Http\Client\IClientService; @@ -580,6 +581,22 @@ Raw output $event = new GenericEvent($info); $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event); + $event = new AddMissingPrimaryKeyEvent(); + $this->eventDispatcher->dispatchTyped($event); + $missingKeys = $event->getMissingPrimaryKeys(); + + if (!empty($missingKeys)) { + $schema = new SchemaWrapper(\OCP\Server::get(Connection::class)); + foreach ($missingKeys as $missingKey) { + if ($schema->hasTable($missingKey['tableName'])) { + $table = $schema->getTable($missingKey['tableName']); + if (!$table->hasPrimaryKey()) { + $info->addHintForMissingSubject($missingKey['tableName']); + } + } + } + } + return $info->getListOfMissingPrimaryKeys(); } |