1
0

Version21000Date20201223143245.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Sharing\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version21000Date20201223143245 extends SimpleMigrationStep {
  14. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  15. /** @var ISchemaWrapper $schema */
  16. $schema = $schemaClosure();
  17. if ($schema->hasTable('share_external')) {
  18. $table = $schema->getTable('share_external');
  19. $changed = false;
  20. if (!$table->hasColumn('parent')) {
  21. $table->addColumn('parent', Types::BIGINT, [
  22. 'notnull' => false,
  23. 'default' => -1,
  24. ]);
  25. $changed = true;
  26. }
  27. if (!$table->hasColumn('share_type')) {
  28. $table->addColumn('share_type', Types::INTEGER, [
  29. 'notnull' => false,
  30. 'length' => 4,
  31. ]);
  32. $changed = true;
  33. }
  34. if ($table->hasColumn('lastscan')) {
  35. $table->dropColumn('lastscan');
  36. $changed = true;
  37. }
  38. if ($changed) {
  39. return $schema;
  40. }
  41. }
  42. return null;
  43. }
  44. }