1
0

Version18000Date20191014105105.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\DB\Types;
  11. use OCP\IDBConnection;
  12. use OCP\Migration\IOutput;
  13. use OCP\Migration\SimpleMigrationStep;
  14. class Version18000Date20191014105105 extends SimpleMigrationStep {
  15. public function __construct(
  16. protected IDBConnection $connection,
  17. ) {
  18. }
  19. /**
  20. * @param IOutput $output
  21. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  22. * @param array $options
  23. * @return null|ISchemaWrapper
  24. */
  25. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  26. /** @var ISchemaWrapper $schema */
  27. $schema = $schemaClosure();
  28. $table = $schema->createTable('direct_edit');
  29. $table->addColumn('id', Types::BIGINT, [
  30. 'autoincrement' => true,
  31. 'notnull' => true,
  32. ]);
  33. $table->addColumn('editor_id', Types::STRING, [
  34. 'notnull' => true,
  35. 'length' => 64,
  36. ]);
  37. $table->addColumn('token', Types::STRING, [
  38. 'notnull' => true,
  39. 'length' => 64,
  40. ]);
  41. $table->addColumn('file_id', Types::BIGINT, [
  42. 'notnull' => true,
  43. ]);
  44. $table->addColumn('user_id', Types::STRING, [
  45. 'notnull' => false,
  46. 'length' => 64,
  47. ]);
  48. $table->addColumn('share_id', Types::BIGINT, [
  49. 'notnull' => false
  50. ]);
  51. $table->addColumn('timestamp', Types::BIGINT, [
  52. 'notnull' => true,
  53. 'length' => 20,
  54. 'unsigned' => true,
  55. ]);
  56. $table->addColumn('accessed', Types::BOOLEAN, [
  57. 'notnull' => false,
  58. 'default' => false
  59. ]);
  60. $table->setPrimaryKey(['id']);
  61. $table->addIndex(['token']);
  62. $table->addIndex(['timestamp'], 'direct_edit_timestamp');
  63. return $schema;
  64. }
  65. }