Version18000Date20191014105105.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
  5. *
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  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 OC\Core\Migrations;
  27. use Closure;
  28. use Doctrine\DBAL\Types\Types;
  29. use OCP\DB\ISchemaWrapper;
  30. use OCP\IDBConnection;
  31. use OCP\Migration\SimpleMigrationStep;
  32. use OCP\Migration\IOutput;
  33. class Version18000Date20191014105105 extends SimpleMigrationStep {
  34. /** @var IDBConnection */
  35. protected $connection;
  36. public function __construct(IDBConnection $connection) {
  37. $this->connection = $connection;
  38. }
  39. /**
  40. * @param IOutput $output
  41. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  42. * @param array $options
  43. * @return null|ISchemaWrapper
  44. */
  45. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  46. /** @var ISchemaWrapper $schema */
  47. $schema = $schemaClosure();
  48. $table = $schema->createTable('direct_edit');
  49. $table->addColumn('id', Types::BIGINT, [
  50. 'autoincrement' => true,
  51. 'notnull' => true,
  52. ]);
  53. $table->addColumn('editor_id', Types::STRING, [
  54. 'notnull' => true,
  55. 'length' => 64,
  56. ]);
  57. $table->addColumn('token', Types::STRING, [
  58. 'notnull' => true,
  59. 'length' => 64,
  60. ]);
  61. $table->addColumn('file_id', Types::BIGINT, [
  62. 'notnull' => true,
  63. ]);
  64. $table->addColumn('user_id', Types::STRING, [
  65. 'notnull' => false,
  66. 'length' => 64,
  67. ]);
  68. $table->addColumn('share_id', Types::BIGINT, [
  69. 'notnull' => false
  70. ]);
  71. $table->addColumn('timestamp', Types::BIGINT, [
  72. 'notnull' => true,
  73. 'length' => 20,
  74. 'unsigned' => true,
  75. ]);
  76. $table->addColumn('accessed', Types::BOOLEAN, [
  77. 'notnull' => false,
  78. 'default' => false
  79. ]);
  80. $table->setPrimaryKey(['id']);
  81. $table->addIndex(['token']);
  82. return $schema;
  83. }
  84. }