From 18db96c304c2b2d93c3effc2c1d5b9320fe78ce1 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 14 Jul 2023 10:34:09 +0200 Subject: feat: Add public event for missing indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/public/DB/Events/AddMissingIndicesEvent.php | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/public/DB/Events/AddMissingIndicesEvent.php (limited to 'lib/public/DB/Events/AddMissingIndicesEvent.php') diff --git a/lib/public/DB/Events/AddMissingIndicesEvent.php b/lib/public/DB/Events/AddMissingIndicesEvent.php new file mode 100644 index 00000000000..139b776b136 --- /dev/null +++ b/lib/public/DB/Events/AddMissingIndicesEvent.php @@ -0,0 +1,59 @@ +. + * + */ + +namespace OCP\DB\Events; + +/** + * Event to allow apps to register information about missing database indices + * + * This event will be dispatched for checking on the admin settings and when running + * occ db:add-missing-indices which will then create those indices + * + * @since 28.0.0 + */ +class AddMissingIndicesEvent extends \OCP\EventDispatcher\Event { + /** @var array */ + private array $missingIndices = []; + + /** + * @param string[] $columns + * @since 28.0.0 + */ + public function addMissingIndex(string $tableName, string $indexName, array $columns): void { + $this->missingIndices[] = [ + 'tableName' => $tableName, + 'indexName' => $indexName, + 'columns' => $columns + ]; + } + + /** + * @since 28.0.0 + * @return array + */ + public function getMissingIndices(): array { + return $this->missingIndices; + } +} -- cgit v1.2.3