Version1010Date20200630191755.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\FederatedFileSharing\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 Version1010Date20200630191755 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. * @return null|ISchemaWrapper
  19. */
  20. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('federated_reshares')) {
  24. $table = $schema->createTable('federated_reshares');
  25. $table->addColumn('share_id', Types::BIGINT, [
  26. 'notnull' => true,
  27. ]);
  28. $table->addColumn('remote_id', Types::STRING, [
  29. 'notnull' => false,
  30. 'length' => 255,
  31. 'default' => '',
  32. ]);
  33. $table->setPrimaryKey(['share_id'], 'federated_res_pk');
  34. // $table->addUniqueIndex(['share_id'], 'share_id_index');
  35. }
  36. return $schema;
  37. }
  38. }