Version1010Date20200630192639.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Vincent Petry <vincent@nextcloud.com>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\Files_Trashbin\Migration;
  27. use Closure;
  28. use OCP\DB\ISchemaWrapper;
  29. use OCP\DB\Types;
  30. use OCP\Migration\IOutput;
  31. use OCP\Migration\SimpleMigrationStep;
  32. class Version1010Date20200630192639 extends SimpleMigrationStep {
  33. /**
  34. * @param IOutput $output
  35. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  36. * @param array $options
  37. * @return null|ISchemaWrapper
  38. */
  39. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  40. /** @var ISchemaWrapper $schema */
  41. $schema = $schemaClosure();
  42. if (!$schema->hasTable('files_trash')) {
  43. $table = $schema->createTable('files_trash');
  44. $table->addColumn('auto_id', Types::BIGINT, [
  45. 'autoincrement' => true,
  46. 'notnull' => true,
  47. ]);
  48. $table->addColumn('id', Types::STRING, [
  49. 'notnull' => true,
  50. 'length' => 250,
  51. 'default' => '',
  52. ]);
  53. $table->addColumn('user', Types::STRING, [
  54. 'notnull' => true,
  55. 'length' => 64,
  56. 'default' => '',
  57. ]);
  58. $table->addColumn('timestamp', Types::STRING, [
  59. 'notnull' => true,
  60. 'length' => 12,
  61. 'default' => '',
  62. ]);
  63. $table->addColumn('location', Types::STRING, [
  64. 'notnull' => true,
  65. 'length' => 512,
  66. 'default' => '',
  67. ]);
  68. $table->addColumn('type', Types::STRING, [
  69. 'notnull' => false,
  70. 'length' => 4,
  71. ]);
  72. $table->addColumn('mime', Types::STRING, [
  73. 'notnull' => false,
  74. 'length' => 255,
  75. ]);
  76. $table->setPrimaryKey(['auto_id']);
  77. $table->addIndex(['id'], 'id_index');
  78. $table->addIndex(['timestamp'], 'timestamp_index');
  79. $table->addIndex(['user'], 'user_index');
  80. }
  81. return $schema;
  82. }
  83. }