You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version18000Date20191014105105.php 2.6KB

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