Version2060Date20200302131958   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 175
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 175
ccs 0
cts 151
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B changeSchema() 0 165 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\Richdocuments\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\IOutput;
10
use OCP\Migration\SimpleMigrationStep;
11
12
/**
13
 * Auto-generated migration step: Please modify to your needs!
14
 */
15
class Version2060Date20200302131958 extends SimpleMigrationStep {
16
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 * @return null|ISchemaWrapper
22
	 */
23
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
24
		/** @var ISchemaWrapper $schema */
25
		$schema = $schemaClosure();
26
27
		if (!$schema->hasTable('richdocuments_wopi')) {
28
			$table = $schema->createTable('richdocuments_wopi');
29
			$table->addColumn('id', 'bigint', [
30
				'autoincrement' => true,
31
				'notnull' => true,
32
				'length' => 20,
33
				'unsigned' => true,
34
			]);
35
			$table->addColumn('owner_uid', 'string', [
36
				'notnull' => false,
37
				'length' => 64,
38
			]);
39
			$table->addColumn('editor_uid', 'string', [
40
				'notnull' => false,
41
				'length' => 64,
42
			]);
43
			$table->addColumn('guest_displayname', 'string', [
44
				'notnull' => false,
45
				'length' => 64,
46
			]);
47
			$table->addColumn('fileid', 'bigint', [
48
				'notnull' => true,
49
				'length' => 20,
50
			]);
51
			$table->addColumn('version', 'bigint', [
52
				//'notnull' => true,
53
				'notnull' => false,
54
				'length' => 20,
55
				'default' => 0,
56
			]);
57
			$table->addColumn('canwrite', 'boolean', [
58
				//'notnull' => true,
59
				'notnull' => false,
60
				'default' => false,
61
			]);
62
			$table->addColumn('server_host', 'string', [
63
				'notnull' => true,
64
				'default' => 'localhost',
65
			]);
66
			$table->addColumn('token', 'string', [
67
				//'notnull' => true,
68
				'notnull' => false,
69
				'length' => 32,
70
				'default' => '',
71
			]);
72
			$table->addColumn('expiry', 'bigint', [
73
				'notnull' => false,
74
				'length' => 20,
75
				'unsigned' => true,
76
			]);
77
			$table->addColumn('template_destination', 'bigint', [
78
				'notnull' => false,
79
				'length' => 20,
80
			]);
81
			$table->addColumn('template_id', 'bigint', [
82
				'notnull' => false,
83
				'length' => 20,
84
			]);
85
			$table->addColumn('hide_download', 'boolean', [
86
				// 'notnull' => true,
87
				'notnull' => false,
88
				'default' => false,
89
			]);
90
			$table->addColumn('direct', 'boolean', [
91
				// 'notnull' => true,
92
				'notnull' => false,
93
				'default' => false,
94
			]);
95
			$table->addColumn('is_remote_token', 'boolean', [
96
				// 'notnull' => true,
97
				'notnull' => false,
98
				'default' => false,
99
			]);
100
			$table->addColumn('remote_server', 'string', [
101
				// 'notnull' => true,
102
				'notnull' => false,
103
				'default' => '',
104
			]);
105
			$table->addColumn('remote_server_token', 'string', [
106
				// 'notnull' => true,
107
				'notnull' => false,
108
				'length' => 32,
109
				'default' => '',
110
			]);
111
			$table->setPrimaryKey(['id']);
112
			$table->addUniqueIndex(['token'], 'rd_wopi_token_idx');
113
		}
114
115
		if (!$schema->hasTable('richdocuments_direct')) {
116
			$table = $schema->createTable('richdocuments_direct');
117
			$table->addColumn('id', 'bigint', [
118
				'autoincrement' => true,
119
				'notnull' => true,
120
				'length' => 20,
121
				'unsigned' => true,
122
			]);
123
			$table->addColumn('token', 'string', [
124
				'notnull' => false,
125
				'length' => 64,
126
			]);
127
			$table->addColumn('uid', 'string', [
128
				'notnull' => false,
129
				'length' => 64,
130
			]);
131
			$table->addColumn('fileid', 'bigint', [
132
				'notnull' => true,
133
				'length' => 20,
134
			]);
135
			$table->addColumn('timestamp', 'bigint', [
136
				// 'notnull' => true,
137
				'notnull' => false,
138
				'length' => 20,
139
				'default' => 0,
140
				'unsigned' => true,
141
			]);
142
			$table->addColumn('template_destination', 'bigint', [
143
				'notnull' => false,
144
				'length' => 20,
145
			]);
146
			$table->addColumn('template_id', 'bigint', [
147
				'notnull' => false,
148
				'length' => 20,
149
			]);
150
			$table->setPrimaryKey(['id']);
151
			$table->addUniqueIndex(['token'], 'rd_direct_token_idx');
152
			$table->addIndex(['timestamp'], 'rd_direct_timestamp_idx');
153
		}
154
155
		if (!$schema->hasTable('richdocuments_assets')) {
156
			$table = $schema->createTable('richdocuments_assets');
157
			$table->addColumn('id', 'bigint', [
158
				'autoincrement' => true,
159
				'notnull' => true,
160
				'length' => 20,
161
				'unsigned' => true,
162
			]);
163
			$table->addColumn('uid', 'string', [
164
				'notnull' => false,
165
				'length' => 64,
166
			]);
167
			$table->addColumn('fileid', 'bigint', [
168
				'notnull' => true,
169
				'length' => 20,
170
			]);
171
			$table->addColumn('token', 'string', [
172
				'notnull' => false,
173
				'length' => 64,
174
			]);
175
			$table->addColumn('timestamp', 'bigint', [
176
				// 'notnull' => true,
177
				'notnull' => false,
178
				'length' => 20,
179
				'default' => 0,
180
				'unsigned' => true,
181
			]);
182
			$table->setPrimaryKey(['id']);
183
			$table->addUniqueIndex(['token'], 'rd_assets_token_idx');
184
			$table->addUniqueIndex(['timestamp'], 'rd_assets_timestamp_idx');
185
		}
186
		return $schema;
187
	}
188
189
}
190