1
0

Version1005Date20180413093149.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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\DAV\Migration;
  27. use OCP\DB\ISchemaWrapper;
  28. use OCP\DB\Types;
  29. use OCP\Migration\IOutput;
  30. use OCP\Migration\SimpleMigrationStep;
  31. class Version1005Date20180413093149 extends SimpleMigrationStep {
  32. /**
  33. * @param IOutput $output
  34. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  35. * @param array $options
  36. * @return null|ISchemaWrapper
  37. */
  38. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  39. /** @var ISchemaWrapper $schema */
  40. $schema = $schemaClosure();
  41. if (!$schema->hasTable('directlink')) {
  42. $table = $schema->createTable('directlink');
  43. $table->addColumn('id', Types::BIGINT, [
  44. 'autoincrement' => true,
  45. 'notnull' => true,
  46. 'length' => 11,
  47. 'unsigned' => true,
  48. ]);
  49. $table->addColumn('user_id', Types::STRING, [
  50. 'notnull' => false,
  51. 'length' => 64,
  52. ]);
  53. $table->addColumn('file_id', Types::BIGINT, [
  54. 'notnull' => true,
  55. 'length' => 11,
  56. 'unsigned' => true,
  57. ]);
  58. $table->addColumn('token', Types::STRING, [
  59. 'notnull' => false,
  60. 'length' => 60,
  61. ]);
  62. $table->addColumn('expiration', Types::BIGINT, [
  63. 'notnull' => true,
  64. 'length' => 11,
  65. 'unsigned' => true,
  66. ]);
  67. $table->setPrimaryKey(['id'], 'directlink_id_idx');
  68. $table->addIndex(['token'], 'directlink_token_idx');
  69. $table->addIndex(['expiration'], 'directlink_expiration_idx');
  70. return $schema;
  71. }
  72. }
  73. }