Version1008Date20181105104826.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 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\IDBConnection;
  12. use OCP\Migration\IOutput;
  13. use OCP\Migration\SimpleMigrationStep;
  14. class Version1008Date20181105104826 extends SimpleMigrationStep {
  15. /**
  16. * Version1008Date20181105104826 constructor.
  17. *
  18. * @param IDBConnection $connection
  19. */
  20. public function __construct(
  21. private IDBConnection $connection,
  22. ) {
  23. }
  24. /**
  25. * @param IOutput $output
  26. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  27. * @param array $options
  28. * @return null|ISchemaWrapper
  29. */
  30. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  31. /** @var ISchemaWrapper $schema */
  32. $schema = $schemaClosure();
  33. $table = $schema->getTable('calendarsubscriptions');
  34. $table->addColumn('source_copy', Types::TEXT, [
  35. 'notnull' => false,
  36. 'length' => null,
  37. ]);
  38. return $schema;
  39. }
  40. /**
  41. * @param IOutput $output
  42. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  43. * @param array $options
  44. */
  45. public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
  46. $qb = $this->connection->getQueryBuilder();
  47. $qb->update('calendarsubscriptions')
  48. ->set('source_copy', 'source')
  49. ->execute();
  50. }
  51. }