aboutsummaryrefslogtreecommitdiffstats
path: root/core/Application.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-07-19 23:10:13 +0200
committerJoas Schilling <coding@schilljs.com>2023-07-24 14:51:33 +0200
commit77c2b169a5da0d7cbb8269f8b240fa47edff90b7 (patch)
tree17497ae4a3b104882bf59f7a42d9bb76dedf2c4a /core/Application.php
parentbd0a149a4ffa2a2e398dddb99f4b0d486bfc2cb7 (diff)
downloadnextcloud-server-77c2b169a5da0d7cbb8269f8b240fa47edff90b7.tar.gz
nextcloud-server-77c2b169a5da0d7cbb8269f8b240fa47edff90b7.zip
fix(db): Move missing core primary keys to typed event
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Application.php')
-rw-r--r--core/Application.php100
1 files changed, 44 insertions, 56 deletions
diff --git a/core/Application.php b/core/Application.php
index 592e0929666..d6f0f959964 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -54,6 +54,7 @@ use OC\Metadata\FileEventListener;
use OC\TagManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
+use OCP\DB\Events\AddMissingPrimaryKeyEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
@@ -253,62 +254,49 @@ 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(Connection::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());
- }
- }
- }
- );
+ $eventDispatcher->addListener(AddMissingPrimaryKeyEvent::class, function (AddMissingPrimaryKeyEvent $event) {
+ $event->addMissingPrimaryKey(
+ 'federated_reshares',
+ 'federated_res_pk',
+ ['share_id'],
+ 'share_id_index'
+ );
+
+ $event->addMissingPrimaryKey(
+ 'systemtag_object_mapping',
+ 'som_pk',
+ ['objecttype', 'objectid', 'systemtagid'],
+ 'mapping'
+ );
+
+ $event->addMissingPrimaryKey(
+ 'comments_read_markers',
+ 'crm_pk',
+ ['user_id', 'object_type', 'object_id'],
+ 'comments_marker_index'
+ );
+
+ $event->addMissingPrimaryKey(
+ 'collres_resources',
+ 'crr_pk',
+ ['collection_id', 'resource_type', 'resource_id'],
+ 'collres_unique_res'
+ );
+
+ $event->addMissingPrimaryKey(
+ 'collres_accesscache',
+ 'cra_pk',
+ ['user_id', 'collection_id', 'resource_type', 'resource_id'],
+ 'collres_unique_user'
+ );
+
+ $event->addMissingPrimaryKey(
+ 'filecache_extended',
+ 'fce_pk',
+ ['fileid'],
+ 'fce_fileid_idx'
+ );
+ });
$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT,
function (GenericEvent $event) use ($container) {