From 5f49b6c0048c9a0b934bf50bf3ea508babb9becd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jun 2020 21:36:14 +0200 Subject: [PATCH] Move to migrations Signed-off-by: Joas Schilling --- appinfo/database.xml | 81 ----------------- appinfo/info.xml | 2 +- .../Version3001Date20200630193443.php | 91 +++++++++++++++++++ 3 files changed, 92 insertions(+), 82 deletions(-) delete mode 100644 appinfo/database.xml create mode 100644 lib/Migration/Version3001Date20200630193443.php diff --git a/appinfo/database.xml b/appinfo/database.xml deleted file mode 100644 index d693d37..0000000 --- a/appinfo/database.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - *dbname* - true - false - utf8 - - - *dbprefix*user_saml_users - - - uid - text - - true - true - 64 - - - - displayname - text - - true - 255 - - - - home - text - - true - 255 - - - -
- - - - *dbprefix*user_saml_auth_token - - - - id - integer - 0 - true - 1 - true - 4 - - - - - uid - text - - true - 64 - - - - name - clob - - true - - - - token - text - - true - 200 - - -
-
diff --git a/appinfo/info.xml b/appinfo/info.xml index cf686f1..2546b35 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -16,7 +16,7 @@ The following providers are supported and tested at the moment: * Any other provider that authenticates using the environment variable While theoretically any other authentication provider implementing either one of those standards is compatible, we like to note that they are not part of any internal test matrix.]]> - 3.1.0 + 3.1.1 agpl Lukas Reschke User_SAML diff --git a/lib/Migration/Version3001Date20200630193443.php b/lib/Migration/Version3001Date20200630193443.php new file mode 100644 index 0000000..de709be --- /dev/null +++ b/lib/Migration/Version3001Date20200630193443.php @@ -0,0 +1,91 @@ + + * + * @author Joas Schilling + * + * @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 . + * + */ + +namespace OCA\User_SAML\Migration; + +use Closure; +use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version3001Date20200630193443 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('user_saml_users')) { + $table = $schema->createTable('user_saml_users'); + $table->addColumn('uid', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + 'default' => '', + ]); + $table->addColumn('displayname', Type::STRING, [ + 'notnull' => true, + 'length' => 255, + 'default' => '', + ]); + $table->addColumn('home', Type::STRING, [ + 'notnull' => true, + 'length' => 255, + 'default' => '', + ]); + $table->setPrimaryKey(['uid']); + } + + if (!$schema->hasTable('user_saml_auth_token')) { + $table = $schema->createTable('user_saml_auth_token'); + $table->addColumn('id', Type::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 4, + 'unsigned' => true, + ]); + $table->addColumn('uid', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + 'default' => '', + ]); + $table->addColumn('name', Type::TEXT, [ + 'notnull' => true, + 'default' => '', + ]); + $table->addColumn('token', Type::STRING, [ + 'notnull' => true, + 'length' => 200, + 'default' => '', + ]); + $table->setPrimaryKey(['id']); + } + return $schema; + } +}