Skip to content

Commit f68001f

Browse files
committed
Change DB migration to use URI hash rather than full URL.
1 parent 2b4cffe commit f68001f

File tree

2 files changed

+58
-55
lines changed

2 files changed

+58
-55
lines changed

solid/lib/Migration/Version000000Date20220923134100.php

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 Version000000Date20221020145600 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+
// As the JTI table should only contain short-lived data anyway, it can safely be dropped
27+
if ($schema->hasTable('solid_jti') === true) {
28+
$schema->dropTable('solid_jti');
29+
}
30+
31+
$table = $schema->createTable('solid_jti');
32+
33+
$table->addColumn('id', Types::INTEGER, [
34+
'autoincrement' => true,
35+
'notnull' => true,
36+
]);
37+
38+
$table->addColumn('jti', Types::STRING, [
39+
'length' => 255,
40+
'notnull' => true,
41+
]);
42+
43+
$table->addColumn('uri', Types::STRING, [
44+
'length' => 40,
45+
'notnull' => true,
46+
]);
47+
48+
$table->addColumn('request_time', Types::DATETIME, [
49+
'default' => 'CURRENT_TIMESTAMP',
50+
'notnull' => true,
51+
]);
52+
53+
$table->setPrimaryKey(['id']);
54+
$table->addIndex(['jti', 'uri']);
55+
56+
return $schema;
57+
}
58+
}

0 commit comments

Comments
 (0)