1
0

Version1008Date20181105110300.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Georg Ehrke
  4. *
  5. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. declare(strict_types=1);
  26. namespace OCA\DAV\Migration;
  27. use Closure;
  28. use Doctrine\DBAL\Types\Types;
  29. use OCP\DB\ISchemaWrapper;
  30. use OCP\IDBConnection;
  31. use OCP\Migration\IOutput;
  32. use OCP\Migration\SimpleMigrationStep;
  33. class Version1008Date20181105110300 extends SimpleMigrationStep {
  34. /** @var IDBConnection */
  35. private $connection;
  36. /**
  37. * Version1008Date20181105110300 constructor.
  38. *
  39. * @param IDBConnection $connection
  40. */
  41. public function __construct(IDBConnection $connection) {
  42. $this->connection = $connection;
  43. }
  44. /**
  45. * @param IOutput $output
  46. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  47. * @param array $options
  48. * @return null|ISchemaWrapper
  49. */
  50. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  51. /** @var ISchemaWrapper $schema */
  52. $schema = $schemaClosure();
  53. $table = $schema->getTable('calendarsubscriptions');
  54. $table->addColumn('source', Types::TEXT, [
  55. 'notnull' => false,
  56. 'length' => null,
  57. ]);
  58. return $schema;
  59. }
  60. /**
  61. * @param IOutput $output
  62. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  63. * @param array $options
  64. */
  65. public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
  66. $qb = $this->connection->getQueryBuilder();
  67. $qb->update('calendarsubscriptions')
  68. ->set('source', 'source_copy')
  69. ->execute();
  70. }
  71. }