Passed
Push — master ( b39fb5...590849 )
by Roeland
11:59 queued 10s
created

Version19000Date20200211083441   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 31 2
1
<?php
2
declare(strict_types=1);
3
4
namespace OC\Core\Migrations;
5
6
use Closure;
7
use OCP\DB\ISchemaWrapper;
8
use OCP\Migration\IOutput;
9
use OCP\Migration\SimpleMigrationStep;
10
11
class Version19000Date20200211083441 extends SimpleMigrationStep {
12
13
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
14
		/** @var ISchemaWrapper $schema */
15
		$schema = $schemaClosure();
16
17
		if (!$schema->hasTable('webauthn')) {
18
			$table = $schema->createTable('webauthn');
19
			$table->addColumn('id', 'integer', [
20
				'autoincrement' => true,
21
				'notnull' => true,
22
				'length' => 64,
23
			]);
24
			$table->addColumn('uid', 'string', [
25
				'notnull' => true,
26
				'length' => 64,
27
			]);
28
			$table->addColumn('name', 'string', [
29
				'notnull' => true,
30
				'length' => 64,
31
			]);
32
			$table->addColumn('public_key_credential_id', 'string', [
33
				'notnull' => true,
34
				'length' => 255
35
			]);
36
			$table->addColumn('data', 'text', [
37
				'notnull' => true,
38
			]);
39
			$table->setPrimaryKey(['id']);
40
			$table->addIndex(['uid'], 'webauthn_uid');
41
			$table->addIndex(['public_key_credential_id'], 'webauthn_publicKeyCredentialId');
42
		}
43
		return $schema;
44
	}
45
}
46