You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version16000Date20190427105638.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Migrations;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\IDBConnection;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version16000Date20190427105638 extends SimpleMigrationStep {
  14. public function __construct(
  15. private IDBConnection $connection,
  16. ) {
  17. }
  18. /**
  19. * @param IOutput $output
  20. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  21. * @param array $options
  22. */
  23. public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
  24. $this->connection
  25. ->getQueryBuilder()
  26. ->delete('collres_accesscache')
  27. ->execute();
  28. }
  29. /**
  30. * @param IOutput $output
  31. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  32. * @param array $options
  33. * @return null|ISchemaWrapper
  34. * @throws \Doctrine\DBAL\Schema\SchemaException
  35. */
  36. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  37. /** @var ISchemaWrapper $schema */
  38. $schema = $schemaClosure();
  39. if ($schema->hasTable('collres_accesscache')) {
  40. $table = $schema->getTable('collres_accesscache');
  41. $table->dropColumn('access');
  42. }
  43. return $schema;
  44. }
  45. }