Version1008Date20181105110300.php 2.2 KB

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