Version1010Date20200630192639.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_Trashbin\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 Version1010Date20200630192639 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('files_trash')) {
  24. $table = $schema->createTable('files_trash');
  25. $table->addColumn('auto_id', Types::BIGINT, [
  26. 'autoincrement' => true,
  27. 'notnull' => true,
  28. ]);
  29. $table->addColumn('id', Types::STRING, [
  30. 'notnull' => true,
  31. 'length' => 250,
  32. 'default' => '',
  33. ]);
  34. $table->addColumn('user', Types::STRING, [
  35. 'notnull' => true,
  36. 'length' => 64,
  37. 'default' => '',
  38. ]);
  39. $table->addColumn('timestamp', Types::STRING, [
  40. 'notnull' => true,
  41. 'length' => 12,
  42. 'default' => '',
  43. ]);
  44. $table->addColumn('location', Types::STRING, [
  45. 'notnull' => true,
  46. 'length' => 512,
  47. 'default' => '',
  48. ]);
  49. $table->addColumn('type', Types::STRING, [
  50. 'notnull' => false,
  51. 'length' => 4,
  52. ]);
  53. $table->addColumn('mime', Types::STRING, [
  54. 'notnull' => false,
  55. 'length' => 255,
  56. ]);
  57. $table->setPrimaryKey(['auto_id']);
  58. $table->addIndex(['id'], 'id_index');
  59. $table->addIndex(['timestamp'], 'timestamp_index');
  60. $table->addIndex(['user'], 'user_index');
  61. }
  62. return $schema;
  63. }
  64. }