diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-10 09:34:57 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-11-10 15:36:27 +0100 |
commit | d5df033ede1f2b19b87c365b1f808130023edf17 (patch) | |
tree | d00503789c2e1188d59726e221dd9445e858f784 /core/Application.php | |
parent | 5b5aebbf66e7559aac73eb82b236b052b6a1ae3e (diff) | |
download | nextcloud-server-d5df033ede1f2b19b87c365b1f808130023edf17.tar.gz nextcloud-server-d5df033ede1f2b19b87c365b1f808130023edf17.zip |
Create primary keys on all tables and add a command to create the afterwards
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Application.php')
-rw-r--r-- | core/Application.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/core/Application.php b/core/Application.php index a452ca9677f..d9d6b92a2ad 100644 --- a/core/Application.php +++ b/core/Application.php @@ -42,6 +42,7 @@ use OC\Authentication\Notifications\Notifier as AuthenticationNotifier; use OC\Core\Notification\RemoveLinkSharesNotifier; use OC\DB\MissingColumnInformation; use OC\DB\MissingIndexInformation; +use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OCP\AppFramework\App; use OCP\EventDispatcher\IEventDispatcher; @@ -181,6 +182,63 @@ class Application extends App { } ); + $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, + function (GenericEvent $event) use ($container) { + /** @var MissingPrimaryKeyInformation $subject */ + $subject = $event->getSubject(); + + $schema = new SchemaWrapper($container->query(IDBConnection::class)); + + if ($schema->hasTable('federated_reshares')) { + $table = $schema->getTable('federated_reshares'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('systemtag_object_mapping')) { + $table = $schema->getTable('systemtag_object_mapping'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('comments_read_markers')) { + $table = $schema->getTable('comments_read_markers'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('collres_resources')) { + $table = $schema->getTable('collres_resources'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('collres_accesscache')) { + $table = $schema->getTable('collres_accesscache'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('filecache_extended')) { + $table = $schema->getTable('filecache_extended'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + } + ); + $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, function (GenericEvent $event) use ($container) { /** @var MissingColumnInformation $subject */ |