Version1008Date20181105104826.php 1.5 KB

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