Version1008Date20181105110300.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Version1008Date20181105110300 extends SimpleMigrationStep {
  15. /**
  16. * Version1008Date20181105110300 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', 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', 'source_copy')
  49. ->execute();
  50. }
  51. }