Version16000Date20190427105638.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OC\Core\Migrations;
  23. use Closure;
  24. use OCP\DB\ISchemaWrapper;
  25. use OCP\IDBConnection;
  26. use OCP\Migration\SimpleMigrationStep;
  27. use OCP\Migration\IOutput;
  28. class Version16000Date20190427105638 extends SimpleMigrationStep {
  29. /** @var IDBConnection */
  30. private $connection;
  31. public function __construct(IDBConnection $connection) {
  32. $this->connection = $connection;
  33. }
  34. /**
  35. * @param IOutput $output
  36. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  37. * @param array $options
  38. */
  39. public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
  40. $this->connection
  41. ->getQueryBuilder()
  42. ->delete('collres_accesscache')
  43. ->execute();
  44. }
  45. /**
  46. * @param IOutput $output
  47. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  48. * @param array $options
  49. * @return null|ISchemaWrapper
  50. * @throws \Doctrine\DBAL\Schema\SchemaException
  51. * @throws \Doctrine\DBAL\DBALException
  52. */
  53. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  54. /** @var ISchemaWrapper $schema */
  55. $schema = $schemaClosure();
  56. if ($schema->hasTable('collres_accesscache')) {
  57. $table = $schema->getTable('collres_accesscache');
  58. $table->dropColumn('access');
  59. }
  60. return $schema;
  61. }
  62. }