1
0

Version12101Date20221011153334.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files\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 Version12101Date20221011153334 extends SimpleMigrationStep {
  14. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  15. /** @var ISchemaWrapper $schema */
  16. $schema = $schemaClosure();
  17. $table = $schema->createTable('open_local_editor');
  18. $table->addColumn('id', Types::BIGINT, [
  19. 'autoincrement' => true,
  20. 'notnull' => true,
  21. 'length' => 20,
  22. 'unsigned' => true,
  23. ]);
  24. $table->addColumn('user_id', Types::STRING, [
  25. 'notnull' => true,
  26. 'length' => 64,
  27. ]);
  28. $table->addColumn('path_hash', Types::STRING, [
  29. 'notnull' => true,
  30. 'length' => 64,
  31. ]);
  32. $table->addColumn('expiration_time', Types::BIGINT, [
  33. 'notnull' => true,
  34. 'unsigned' => true,
  35. ]);
  36. $table->addColumn('token', Types::STRING, [
  37. 'notnull' => true,
  38. 'length' => 128,
  39. ]);
  40. $table->setPrimaryKey(['id']);
  41. $table->addUniqueIndex(['user_id', 'path_hash', 'token'], 'openlocal_user_path_token');
  42. return $schema;
  43. }
  44. }