Version1016Date20201109085907.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 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\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. class Version1016Date20201109085907 extends SimpleMigrationStep {
  13. /**
  14. * @param IOutput $output
  15. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  16. * @param array $options
  17. * @return null|ISchemaWrapper
  18. */
  19. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring');
  23. return $result ? $schema : null;
  24. }
  25. protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool {
  26. $table = $schema->getTable($tableName);
  27. $column = $table->getColumn($columnName);
  28. if ($column->getNotnull()) {
  29. $column->setNotnull(false);
  30. return true;
  31. }
  32. return false;
  33. }
  34. }