2017-09-19 12:37:30 +00:00
|
|
|
<?php
|
2021-04-14 15:05:19 +00:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-09-19 12:37:30 +00:00
|
|
|
/**
|
2024-05-30 18:13:41 +00:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-09-19 12:37:30 +00:00
|
|
|
*/
|
|
|
|
namespace OCA\TwoFactorBackupCodes\Migration;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Types\Type;
|
2020-06-30 20:12:06 +00:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2018-01-17 10:35:20 +00:00
|
|
|
use OCP\DB\ISchemaWrapper;
|
2017-09-19 12:37:30 +00:00
|
|
|
use OCP\Migration\IOutput;
|
2019-11-22 19:52:10 +00:00
|
|
|
use OCP\Migration\SimpleMigrationStep;
|
2017-09-19 12:37:30 +00:00
|
|
|
|
|
|
|
class Version1002Date20170919123342 extends SimpleMigrationStep {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IOutput $output
|
2018-01-17 10:35:20 +00:00
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
2017-09-19 12:37:30 +00:00
|
|
|
* @param array $options
|
2018-01-17 10:35:20 +00:00
|
|
|
* @return null|ISchemaWrapper
|
2017-09-19 12:37:30 +00:00
|
|
|
* @since 13.0.0
|
|
|
|
*/
|
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
2018-01-17 10:35:20 +00:00
|
|
|
/** @var ISchemaWrapper $schema */
|
2017-09-19 12:37:30 +00:00
|
|
|
$schema = $schemaClosure();
|
|
|
|
|
|
|
|
$table = $schema->getTable('twofactor_backupcodes');
|
|
|
|
$column = $table->getColumn('user_id');
|
|
|
|
$column->setDefault('');
|
|
|
|
|
|
|
|
$column = $table->getColumn('used');
|
2020-06-30 20:12:06 +00:00
|
|
|
if ($column->getType()->getName() !== Types::SMALLINT) {
|
|
|
|
$column->setType(Type::getType(Types::SMALLINT));
|
2017-09-19 12:37:30 +00:00
|
|
|
$column->setOptions(['length' => 6]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
|
|
|
}
|