Version1005Date20180413093149.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Migration;
  8. use OCP\DB\ISchemaWrapper;
  9. use OCP\DB\Types;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. class Version1005Date20180413093149 extends SimpleMigrationStep {
  13. /**
  14. * @param IOutput $output
  15. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  16. * @param array $options
  17. * @return null|ISchemaWrapper
  18. */
  19. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. if (!$schema->hasTable('directlink')) {
  23. $table = $schema->createTable('directlink');
  24. $table->addColumn('id', Types::BIGINT, [
  25. 'autoincrement' => true,
  26. 'notnull' => true,
  27. 'length' => 11,
  28. 'unsigned' => true,
  29. ]);
  30. $table->addColumn('user_id', Types::STRING, [
  31. 'notnull' => false,
  32. 'length' => 64,
  33. ]);
  34. $table->addColumn('file_id', Types::BIGINT, [
  35. 'notnull' => true,
  36. 'length' => 11,
  37. 'unsigned' => true,
  38. ]);
  39. $table->addColumn('token', Types::STRING, [
  40. 'notnull' => false,
  41. 'length' => 60,
  42. ]);
  43. $table->addColumn('expiration', Types::BIGINT, [
  44. 'notnull' => true,
  45. 'length' => 11,
  46. 'unsigned' => true,
  47. ]);
  48. $table->setPrimaryKey(['id'], 'directlink_id_idx');
  49. $table->addIndex(['token'], 'directlink_token_idx');
  50. $table->addIndex(['expiration'], 'directlink_expiration_idx');
  51. return $schema;
  52. }
  53. }
  54. }