1
0

Version16000Date20190212081545.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 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 Joas Schilling <coding@schilljs.com>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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\ISchemaWrapper;
  30. use OCP\DB\Types;
  31. use OCP\Migration\IOutput;
  32. use OCP\Migration\SimpleMigrationStep;
  33. class Version16000Date20190212081545 extends SimpleMigrationStep {
  34. /**
  35. * @param IOutput $output
  36. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  37. * @param array $options
  38. *
  39. * @return ISchemaWrapper
  40. */
  41. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
  42. /** @var ISchemaWrapper $schema */
  43. $schema = $schemaClosure();
  44. $table = $schema->createTable('login_flow_v2');
  45. $table->addColumn('id', Types::BIGINT, [
  46. 'autoincrement' => true,
  47. 'notnull' => true,
  48. 'length' => 20,
  49. 'unsigned' => true,
  50. ]);
  51. $table->addColumn('timestamp', Types::BIGINT, [
  52. 'notnull' => true,
  53. 'length' => 20,
  54. 'unsigned' => true,
  55. ]);
  56. $table->addColumn('started', Types::SMALLINT, [
  57. 'notnull' => true,
  58. 'length' => 1,
  59. 'unsigned' => true,
  60. 'default' => 0,
  61. ]);
  62. $table->addColumn('poll_token', Types::STRING, [
  63. 'notnull' => true,
  64. 'length' => 255,
  65. ]);
  66. $table->addColumn('login_token', Types::STRING, [
  67. 'notnull' => true,
  68. 'length' => 255,
  69. ]);
  70. $table->addColumn('public_key', Types::TEXT, [
  71. 'notnull' => true,
  72. 'length' => 32768,
  73. ]);
  74. $table->addColumn('private_key', Types::TEXT, [
  75. 'notnull' => true,
  76. 'length' => 32768,
  77. ]);
  78. $table->addColumn('client_name', Types::STRING, [
  79. 'notnull' => true,
  80. 'length' => 255,
  81. ]);
  82. $table->addColumn('login_name', Types::STRING, [
  83. 'notnull' => false,
  84. 'length' => 255,
  85. ]);
  86. $table->addColumn('server', Types::STRING, [
  87. 'notnull' => false,
  88. 'length' => 255,
  89. ]);
  90. $table->addColumn('app_password', Types::STRING, [
  91. 'notnull' => false,
  92. 'length' => 1024,
  93. ]);
  94. $table->setPrimaryKey(['id']);
  95. $table->addUniqueIndex(['poll_token'], 'poll_token');
  96. $table->addUniqueIndex(['login_token'], 'login_token');
  97. $table->addIndex(['timestamp'], 'timestamp');
  98. return $schema;
  99. }
  100. }