Version1002Date20170919123342.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  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 OCA\TwoFactorBackupCodes\Migration;
  27. use Doctrine\DBAL\Types\Type;
  28. use Doctrine\DBAL\Types\Types;
  29. use OCP\DB\ISchemaWrapper;
  30. use OCP\Migration\IOutput;
  31. use OCP\Migration\SimpleMigrationStep;
  32. class Version1002Date20170919123342 extends SimpleMigrationStep {
  33. /**
  34. * @param IOutput $output
  35. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  36. * @param array $options
  37. * @return null|ISchemaWrapper
  38. * @since 13.0.0
  39. */
  40. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  41. /** @var ISchemaWrapper $schema */
  42. $schema = $schemaClosure();
  43. $table = $schema->getTable('twofactor_backupcodes');
  44. $column = $table->getColumn('user_id');
  45. $column->setDefault('');
  46. $column = $table->getColumn('used');
  47. if ($column->getType()->getName() !== Types::SMALLINT) {
  48. $column->setType(Type::getType(Types::SMALLINT));
  49. $column->setOptions(['length' => 6]);
  50. }
  51. return $schema;
  52. }
  53. }