diff options
author | Joas Schilling <coding@schilljs.com> | 2023-07-19 22:36:59 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-07-24 14:51:32 +0200 |
commit | 2eded24eff5f3f0c911ffbd5841178030c8f9363 (patch) | |
tree | 3f073316f1aac7cd4669fbb2216ab12ed466ff07 /lib/public/DB | |
parent | 7548e62181832dca36fa1a6ad4ec715d71fe83e6 (diff) | |
download | nextcloud-server-2eded24eff5f3f0c911ffbd5841178030c8f9363.tar.gz nextcloud-server-2eded24eff5f3f0c911ffbd5841178030c8f9363.zip |
feat(dispatcher): Add typed event for "db:add-missing-columns"
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/public/DB')
-rw-r--r-- | lib/public/DB/Events/AddMissingColumnsEvent.php | 60 | ||||
-rw-r--r-- | lib/public/DB/Events/AddMissingIndicesEvent.php | 4 |
2 files changed, 62 insertions, 2 deletions
diff --git a/lib/public/DB/Events/AddMissingColumnsEvent.php b/lib/public/DB/Events/AddMissingColumnsEvent.php new file mode 100644 index 00000000000..1fb44e86842 --- /dev/null +++ b/lib/public/DB/Events/AddMissingColumnsEvent.php @@ -0,0 +1,60 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DB\Events; + +/** + * Event to allow apps to register information about missing database columns + * + * This event will be dispatched for checking on the admin settings and when running + * occ db:add-missing-columns which will then create those columns + * + * @since 28.0.0 + */ +class AddMissingColumnsEvent extends \OCP\EventDispatcher\Event { + /** @var array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}> */ + private array $missingColumns = []; + + /** + * @param mixed[] $options + * @since 28.0.0 + */ + public function addMissingColumn(string $tableName, string $columnName, string $typeName, array $options): void { + $this->missingColumns[] = [ + 'tableName' => $tableName, + 'columnName' => $columnName, + 'typeName' => $typeName, + 'options' => $options, + ]; + } + + /** + * @since 28.0.0 + * @return array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}> + */ + public function getMissingColumns(): array { + return $this->missingColumns; + } +} diff --git a/lib/public/DB/Events/AddMissingIndicesEvent.php b/lib/public/DB/Events/AddMissingIndicesEvent.php index 139b776b136..58ba6b34a59 100644 --- a/lib/public/DB/Events/AddMissingIndicesEvent.php +++ b/lib/public/DB/Events/AddMissingIndicesEvent.php @@ -2,9 +2,9 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2023 Julius Härtl <jus@bitgrid.net + * @copyright Copyright (c) 2023 Julius Härtl <jus@bitgrid.net> * - * @author Julius Härtl <jus@bitgrid.net + * @author Julius Härtl <jus@bitgrid.net> * * @license GNU AGPL version 3 or any later version * |