Version1031Date20240610134258.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\Migration\Attributes\AddColumn;
  12. use OCP\Migration\Attributes\ColumnType;
  13. use OCP\Migration\IOutput;
  14. use OCP\Migration\SimpleMigrationStep;
  15. #[AddColumn(table: 'dav_absence', name: 'replacement_user_id', type: ColumnType::STRING)]
  16. #[AddColumn(table: 'dav_absence', name: 'replacement_user_display_name', type: ColumnType::STRING)]
  17. class Version1031Date20240610134258 extends SimpleMigrationStep {
  18. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  19. /** @var ISchemaWrapper $schema */
  20. $schema = $schemaClosure();
  21. $tableDavAbsence = $schema->getTable('dav_absence');
  22. if (!$tableDavAbsence->hasColumn('replacement_user_id')) {
  23. $tableDavAbsence->addColumn('replacement_user_id', Types::STRING, [
  24. 'notnull' => false,
  25. 'default' => '',
  26. 'length' => 64,
  27. ]);
  28. }
  29. if (!$tableDavAbsence->hasColumn('replacement_user_display_name')) {
  30. $tableDavAbsence->addColumn('replacement_user_display_name', Types::STRING, [
  31. 'notnull' => false,
  32. 'default' => '',
  33. 'length' => 64,
  34. ]);
  35. }
  36. return $schema;
  37. }
  38. }