Version1002Date20170919123342.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\TwoFactorBackupCodes\Migration;
  8. use Doctrine\DBAL\Types\Type;
  9. use Doctrine\DBAL\Types\Types;
  10. use OCP\DB\ISchemaWrapper;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version1002Date20170919123342 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. * @return null|ISchemaWrapper
  19. * @since 13.0.0
  20. */
  21. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  22. /** @var ISchemaWrapper $schema */
  23. $schema = $schemaClosure();
  24. $table = $schema->getTable('twofactor_backupcodes');
  25. $column = $table->getColumn('user_id');
  26. $column->setDefault('');
  27. $column = $table->getColumn('used');
  28. if ($column->getType()->getName() !== Types::SMALLINT) {
  29. $column->setType(Type::getType(Types::SMALLINT));
  30. $column->setOptions(['length' => 6]);
  31. }
  32. return $schema;
  33. }
  34. }