Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/twofactor_totp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-10-18 15:48:34 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-10-18 15:48:34 +0300
commit1ee3d78216b0a37128e21d479f3c5034b5640293 (patch)
treecd89978c67c7d32827d09caeb7619405da5ce0e3 /lib
parent9c54692c9a8ea17a6ce3f7fa61f953efd3e260bf (diff)
Move to DB Migrations
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/Migration/Version010501Date20181018124436.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/Migration/Version010501Date20181018124436.php b/lib/Migration/Version010501Date20181018124436.php
new file mode 100644
index 0000000..248e5fe
--- /dev/null
+++ b/lib/Migration/Version010501Date20181018124436.php
@@ -0,0 +1,69 @@
+<?php
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\TwoFactorTOTP\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\SimpleMigrationStep;
+use OCP\Migration\IOutput;
+
+class Version010501Date20181018124436 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('twofactor_totp_secrets')) {
+ $table = $schema->createTable('twofactor_totp_secrets');
+ $table->addColumn('id', 'integer', [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ 'length' => 4,
+ ]);
+ $table->addColumn('user_id', 'string', [
+ 'notnull' => true,
+ 'length' => 64,
+ 'default' => '',
+ ]);
+ $table->addColumn('secret', 'text', [
+ 'notnull' => true,
+ ]);
+ $table->addColumn('state', 'integer', [
+ 'notnull' => true,
+ 'default' => 2,
+ ]);
+ $table->setPrimaryKey(['id']);
+ $table->addUniqueIndex(['user_id'], 'totp_secrets_user_id');
+ }
+ return $schema;
+ }
+}