Skip to content

Commit c61e306

Browse files
committed
Add database migration to create JTI table.
1 parent 718eb32 commit c61e306

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OCA\Solid\Migration;
6+
7+
use Closure;
8+
use OCP\DB\ISchemaWrapper;
9+
use OCP\DB\Types;
10+
use OCP\Migration\SimpleMigrationStep;
11+
use OCP\Migration\IOutput;
12+
13+
class Version000000Date20220923134100 extends SimpleMigrationStep {
14+
/**
15+
* @param IOutput $output
16+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
17+
* @param array $options
18+
*
19+
* @return null|ISchemaWrapper
20+
*/
21+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper
22+
{
23+
/** @var ISchemaWrapper $schema */
24+
$schema = $schemaClosure();
25+
26+
if ($schema->hasTable('solid_jti') === false) {
27+
$table = $schema->createTable('solid_jti');
28+
29+
$table->addColumn('id', Types::INTEGER, [
30+
'autoincrement' => true,
31+
'notnull' => true,
32+
]);
33+
34+
$table->addColumn('jti', Types::STRING, [
35+
'length' => 255,
36+
'notnull' => true,
37+
]);
38+
39+
$table->addColumn('uri', Types::STRING, [
40+
'length' => 2048,
41+
'notnull' => true,
42+
]);
43+
44+
$table->addColumn('request_time', Types::DATETIME, [
45+
'default' => 'CURRENT_TIMESTAMP',
46+
'notnull' => true,
47+
]);
48+
49+
$table->setPrimaryKey(['id']);
50+
$table->addIndex(['jti', 'uri']);
51+
}
52+
53+
return $schema;
54+
}
55+
}

0 commit comments

Comments
 (0)