diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 039089b0..da585b91 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -7,6 +7,7 @@ namespace OCA\ContextChat\AppInfo; +use OCA\ContextChat\Listener\AddMissingIndicesListener; use OCA\ContextChat\Listener\AppDisableListener; use OCA\ContextChat\Listener\FileListener; use OCA\ContextChat\Listener\ShareListener; @@ -20,6 +21,7 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\DB\Events\AddMissingIndicesEvent; use OCP\Files\Cache\CacheEntryInsertedEvent; use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\Events\Node\NodeCreatedEvent; @@ -72,6 +74,7 @@ public function __construct(array $urlParams = []) { } public function register(IRegistrationContext $context): void { + $context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class); $context->registerEventListener(BeforeNodeDeletedEvent::class, FileListener::class); $context->registerEventListener(NodeCreatedEvent::class, FileListener::class); $context->registerEventListener(CacheEntryInsertedEvent::class, FileListener::class); diff --git a/lib/Listener/AddMissingIndicesListener.php b/lib/Listener/AddMissingIndicesListener.php new file mode 100644 index 00000000..0be4378f --- /dev/null +++ b/lib/Listener/AddMissingIndicesListener.php @@ -0,0 +1,32 @@ + + */ +class AddMissingIndicesListener implements IEventListener { + #[\Override] + public function handle(Event $event): void { + if (!($event instanceof AddMissingIndicesEvent)) { + // Unrelated + return; + } + + $event->addMissingIndex( + 'context_chat_fs_events', + 'cc_fs_events_full_idx', + ['user_id', 'type', 'node_id'], + ); + } +} diff --git a/lib/Migration/Version004004002Date20250821125112.php b/lib/Migration/Version004004002Date20250821125112.php deleted file mode 100644 index 6e38f013..00000000 --- a/lib/Migration/Version004004002Date20250821125112.php +++ /dev/null @@ -1,42 +0,0 @@ -hasTable('context_chat_fs_events')) { - $table = $schema->getTable('context_chat_fs_events'); - if (!$table->hasIndex('cc_fs_events_full_idx')) { - $table->addIndex(['user_id', 'type', 'node_id'], 'cc_fs_events_full_idx'); - $schemaChanged = true; - } - } - - return $schemaChanged ? $schema : null; - } -}