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