1
0

Version16000Date20190212081545.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Migrations;
  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 Version16000Date20190212081545 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. *
  19. * @return ISchemaWrapper
  20. */
  21. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
  22. /** @var ISchemaWrapper $schema */
  23. $schema = $schemaClosure();
  24. $table = $schema->createTable('login_flow_v2');
  25. $table->addColumn('id', Types::BIGINT, [
  26. 'autoincrement' => true,
  27. 'notnull' => true,
  28. 'length' => 20,
  29. 'unsigned' => true,
  30. ]);
  31. $table->addColumn('timestamp', Types::BIGINT, [
  32. 'notnull' => true,
  33. 'length' => 20,
  34. 'unsigned' => true,
  35. ]);
  36. $table->addColumn('started', Types::SMALLINT, [
  37. 'notnull' => true,
  38. 'length' => 1,
  39. 'unsigned' => true,
  40. 'default' => 0,
  41. ]);
  42. $table->addColumn('poll_token', Types::STRING, [
  43. 'notnull' => true,
  44. 'length' => 255,
  45. ]);
  46. $table->addColumn('login_token', Types::STRING, [
  47. 'notnull' => true,
  48. 'length' => 255,
  49. ]);
  50. $table->addColumn('public_key', Types::TEXT, [
  51. 'notnull' => true,
  52. 'length' => 32768,
  53. ]);
  54. $table->addColumn('private_key', Types::TEXT, [
  55. 'notnull' => true,
  56. 'length' => 32768,
  57. ]);
  58. $table->addColumn('client_name', Types::STRING, [
  59. 'notnull' => true,
  60. 'length' => 255,
  61. ]);
  62. $table->addColumn('login_name', Types::STRING, [
  63. 'notnull' => false,
  64. 'length' => 255,
  65. ]);
  66. $table->addColumn('server', Types::STRING, [
  67. 'notnull' => false,
  68. 'length' => 255,
  69. ]);
  70. $table->addColumn('app_password', Types::STRING, [
  71. 'notnull' => false,
  72. 'length' => 1024,
  73. ]);
  74. $table->setPrimaryKey(['id']);
  75. $table->addUniqueIndex(['poll_token'], 'poll_token');
  76. $table->addUniqueIndex(['login_token'], 'login_token');
  77. $table->addIndex(['timestamp'], 'timestamp');
  78. return $schema;
  79. }
  80. }