1
0

Version16000Date20190212081545.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Core\Migrations;
  25. use Closure;
  26. use Doctrine\DBAL\Types\Type;
  27. use OCP\DB\ISchemaWrapper;
  28. use OCP\Migration\SimpleMigrationStep;
  29. use OCP\Migration\IOutput;
  30. class Version16000Date20190212081545 extends SimpleMigrationStep {
  31. /**
  32. * @param IOutput $output
  33. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  34. * @param array $options
  35. * @return null|ISchemaWrapper
  36. */
  37. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
  38. /** @var ISchemaWrapper $schema */
  39. $schema = $schemaClosure();
  40. $table = $schema->createTable('login_flow_v2');
  41. $table->addColumn('id', Type::BIGINT, [
  42. 'autoincrement' => true,
  43. 'notnull' => true,
  44. 'length' => 20,
  45. 'unsigned' => true,
  46. ]);
  47. $table->addColumn('timestamp', Type::BIGINT, [
  48. 'notnull' => true,
  49. 'length' => 20,
  50. 'unsigned' => true,
  51. ]);
  52. $table->addColumn('started', Type::SMALLINT, [
  53. 'notnull' => true,
  54. 'length' => 1,
  55. 'unsigned' => true,
  56. 'default' => 0,
  57. ]);
  58. $table->addColumn('poll_token', Type::STRING, [
  59. 'notnull' => true,
  60. 'length' => 255,
  61. ]);
  62. $table->addColumn('login_token', Type::STRING, [
  63. 'notnull' => true,
  64. 'length' => 255,
  65. ]);
  66. $table->addColumn('public_key', Type::TEXT, [
  67. 'notnull' => true,
  68. 'length' => 32768,
  69. ]);
  70. $table->addColumn('private_key', Type::TEXT, [
  71. 'notnull' => true,
  72. 'length' => 32768,
  73. ]);
  74. $table->addColumn('client_name', Type::STRING, [
  75. 'notnull' => true,
  76. 'length' => 255,
  77. ]);
  78. $table->addColumn('login_name', Type::STRING, [
  79. 'notnull' => false,
  80. 'length' => 255,
  81. ]);
  82. $table->addColumn('server', Type::STRING, [
  83. 'notnull' => false,
  84. 'length' => 255,
  85. ]);
  86. $table->addColumn('app_password', Type::STRING, [
  87. 'notnull' => false,
  88. 'length' => 1024,
  89. ]);
  90. $table->setPrimaryKey(['id']);
  91. $table->addUniqueIndex(['poll_token'], 'poll_token');
  92. $table->addUniqueIndex(['login_token'], 'login_token');
  93. $table->addIndex(['timestamp'], 'timestamp');
  94. return $schema;
  95. }
  96. }