move to migrations and add groups table

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-10-08 15:52:03 +02:00 committed by Jonathan Treffler
parent 092cdcda26
commit 6b63c5a4ab

View file

@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
namespace OCA\User_SAML\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version2500Date20191008134400 extends SimpleMigrationStep {
/**
* @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_groups')) {
$table = $schema->createTable('user_saml_groups');
$table->addColumn('gid', Type::STRING, [
'notnull' => true,
'length' => 64,
'default' => '',
]);
$table->addColumn('displayname', Type::STRING, [
'notnull' => true,
'length' => 255,
'default' => '',
]);
$table->setPrimaryKey(['gid']);
}
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']);
}
if (!$schema->hasTable('user_saml_group_members')) {
$table = $schema->createTable('user_saml_group_members');
$table->addColumn('uid', Type::STRING, [
'notnull' => true,
'length' => 64,
'default' => '',
]);
$table->addColumn('gid', Type::STRING, [
'notnull' => true,
'length' => 64,
'default' => '',
]);
$table->addUniqueIndex(['gid', 'uid'], 'idx_group_members');
}
return $schema;
}
}