Completed
Push — master ( 2794d6...2d2c9e )
by Morris
98:13 queued 73:44
created
core/Command/Db/AddMissingIndices.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -41,67 +41,67 @@
 block discarded – undo
41 41
  */
42 42
 class AddMissingIndices extends Command {
43 43
 
44
-	/** @var IDBConnection */
45
-	private $connection;
46
-
47
-	/** @var EventDispatcherInterface */
48
-	private $dispatcher;
49
-
50
-	public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
51
-		parent::__construct();
52
-
53
-		$this->connection = $connection;
54
-		$this->dispatcher = $dispatcher;
55
-	}
56
-
57
-	protected function configure() {
58
-		$this
59
-			->setName('db:add-missing-indices')
60
-			->setDescription('Add missing indices to the database tables');
61
-	}
62
-
63
-	protected function execute(InputInterface $input, OutputInterface $output) {
64
-		$this->addShareTableIndicies($output);
65
-
66
-		// Dispatch event so apps can also update indexes if needed
67
-		$event = new GenericEvent($output);
68
-		$this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
69
-	}
70
-
71
-	/**
72
-	 * add missing indices to the share table
73
-	 *
74
-	 * @param OutputInterface $output
75
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
76
-	 */
77
-	private function addShareTableIndicies(OutputInterface $output) {
78
-
79
-		$output->writeln('<info>Check indices of the share table.</info>');
80
-
81
-		$schema = new SchemaWrapper($this->connection);
82
-		$updated = false;
83
-
84
-		if ($schema->hasTable('share')) {
85
-			$table = $schema->getTable('share');
86
-			if (!$table->hasIndex('share_with_index')) {
87
-				$output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
88
-				$table->addIndex(['share_with'], 'share_with_index');
89
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
90
-				$updated = true;
91
-				$output->writeln('<info>Share table updated successfully.</info>');
92
-			}
93
-
94
-			if (!$table->hasIndex('parent_index')) {
95
-				$output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
96
-				$table->addIndex(['parent'], 'parent_index');
97
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
98
-				$updated = true;
99
-				$output->writeln('<info>Share table updated successfully.</info>');
100
-			}
101
-		}
102
-
103
-		if (!$updated) {
104
-			$output->writeln('<info>Done.</info>');
105
-		}
106
-	}
44
+    /** @var IDBConnection */
45
+    private $connection;
46
+
47
+    /** @var EventDispatcherInterface */
48
+    private $dispatcher;
49
+
50
+    public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
51
+        parent::__construct();
52
+
53
+        $this->connection = $connection;
54
+        $this->dispatcher = $dispatcher;
55
+    }
56
+
57
+    protected function configure() {
58
+        $this
59
+            ->setName('db:add-missing-indices')
60
+            ->setDescription('Add missing indices to the database tables');
61
+    }
62
+
63
+    protected function execute(InputInterface $input, OutputInterface $output) {
64
+        $this->addShareTableIndicies($output);
65
+
66
+        // Dispatch event so apps can also update indexes if needed
67
+        $event = new GenericEvent($output);
68
+        $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
69
+    }
70
+
71
+    /**
72
+     * add missing indices to the share table
73
+     *
74
+     * @param OutputInterface $output
75
+     * @throws \Doctrine\DBAL\Schema\SchemaException
76
+     */
77
+    private function addShareTableIndicies(OutputInterface $output) {
78
+
79
+        $output->writeln('<info>Check indices of the share table.</info>');
80
+
81
+        $schema = new SchemaWrapper($this->connection);
82
+        $updated = false;
83
+
84
+        if ($schema->hasTable('share')) {
85
+            $table = $schema->getTable('share');
86
+            if (!$table->hasIndex('share_with_index')) {
87
+                $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
88
+                $table->addIndex(['share_with'], 'share_with_index');
89
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
90
+                $updated = true;
91
+                $output->writeln('<info>Share table updated successfully.</info>');
92
+            }
93
+
94
+            if (!$table->hasIndex('parent_index')) {
95
+                $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
96
+                $table->addIndex(['parent'], 'parent_index');
97
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
98
+                $updated = true;
99
+                $output->writeln('<info>Share table updated successfully.</info>');
100
+            }
101
+        }
102
+
103
+        if (!$updated) {
104
+            $output->writeln('<info>Done.</info>');
105
+        }
106
+    }
107 107
 }
Please login to merge, or discard this patch.
core/Migrations/Version13000Date20170718121200.php 1 patch
Indentation   +887 added lines, -887 removed lines patch added patch discarded remove patch
@@ -30,892 +30,892 @@
 block discarded – undo
30 30
 
31 31
 class Version13000Date20170718121200 extends SimpleMigrationStep {
32 32
 
33
-	/**
34
-	 * @param IOutput $output
35
-	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
36
-	 * @param array $options
37
-	 * @return null|ISchemaWrapper
38
-	 * @since 13.0.0
39
-	 */
40
-	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
41
-		/** @var ISchemaWrapper $schema */
42
-		$schema = $schemaClosure();
43
-
44
-		if (!$schema->hasTable('appconfig')) {
45
-			$table = $schema->createTable('appconfig');
46
-			$table->addColumn('appid', 'string', [
47
-				'notnull' => true,
48
-				'length' => 32,
49
-				'default' => '',
50
-			]);
51
-			$table->addColumn('configkey', 'string', [
52
-				'notnull' => true,
53
-				'length' => 64,
54
-				'default' => '',
55
-			]);
56
-			$table->addColumn('configvalue', 'text', [
57
-				'notnull' => false,
58
-			]);
59
-			$table->setPrimaryKey(['appid', 'configkey']);
60
-			$table->addIndex(['configkey'], 'appconfig_config_key_index');
61
-			$table->addIndex(['appid'], 'appconfig_appid_key');
62
-		}
63
-
64
-		if (!$schema->hasTable('storages')) {
65
-			$table = $schema->createTable('storages');
66
-			$table->addColumn('id', 'string', [
67
-				'notnull' => false,
68
-				'length' => 64,
69
-			]);
70
-			$table->addColumn('numeric_id', Type::BIGINT, [
71
-				'autoincrement' => true,
72
-				'notnull' => true,
73
-				'length' => 20,
74
-			]);
75
-			$table->addColumn('available', 'integer', [
76
-				'notnull' => true,
77
-				'default' => 1,
78
-			]);
79
-			$table->addColumn('last_checked', 'integer', [
80
-				'notnull' => false,
81
-			]);
82
-			$table->setPrimaryKey(['numeric_id']);
83
-			$table->addUniqueIndex(['id'], 'storages_id_index');
84
-		}
85
-
86
-		if (!$schema->hasTable('mounts')) {
87
-			$table = $schema->createTable('mounts');
88
-			$table->addColumn('id', 'integer', [
89
-				'autoincrement' => true,
90
-				'notnull' => true,
91
-				'length' => 4,
92
-			]);
93
-			$table->addColumn('storage_id', 'integer', [
94
-				'notnull' => true,
95
-			]);
96
-			$table->addColumn('root_id', 'integer', [
97
-				'notnull' => true,
98
-			]);
99
-			$table->addColumn('user_id', 'string', [
100
-				'notnull' => true,
101
-				'length' => 64,
102
-			]);
103
-			$table->addColumn('mount_point', 'string', [
104
-				'notnull' => true,
105
-				'length' => 4000,
106
-			]);
107
-			$table->addColumn('mount_id', 'integer', [
108
-				'notnull' => false,
109
-			]);
110
-			$table->setPrimaryKey(['id']);
111
-			$table->addIndex(['user_id'], 'mounts_user_index');
112
-			$table->addIndex(['storage_id'], 'mounts_storage_index');
113
-			$table->addIndex(['root_id'], 'mounts_root_index');
114
-			$table->addIndex(['mount_id'], 'mounts_mount_id_index');
115
-			$table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
116
-		}
117
-
118
-		if (!$schema->hasTable('mimetypes')) {
119
-			$table = $schema->createTable('mimetypes');
120
-			$table->addColumn('id', Type::BIGINT, [
121
-				'autoincrement' => true,
122
-				'notnull' => true,
123
-				'length' => 20,
124
-			]);
125
-			$table->addColumn('mimetype', 'string', [
126
-				'notnull' => true,
127
-				'length' => 255,
128
-				'default' => '',
129
-			]);
130
-			$table->setPrimaryKey(['id']);
131
-			$table->addUniqueIndex(['mimetype'], 'mimetype_id_index');
132
-		}
133
-
134
-		if (!$schema->hasTable('filecache')) {
135
-			$table = $schema->createTable('filecache');
136
-			$table->addColumn('fileid', Type::BIGINT, [
137
-				'autoincrement' => true,
138
-				'notnull' => true,
139
-				'length' => 20,
140
-			]);
141
-			$table->addColumn('storage', Type::BIGINT, [
142
-				'notnull' => true,
143
-				'length' => 20,
144
-				'default' => 0,
145
-			]);
146
-			$table->addColumn('path', 'string', [
147
-				'notnull' => false,
148
-				'length' => 4000,
149
-			]);
150
-			$table->addColumn('path_hash', 'string', [
151
-				'notnull' => true,
152
-				'length' => 32,
153
-				'default' => '',
154
-			]);
155
-			$table->addColumn('parent', Type::BIGINT, [
156
-				'notnull' => true,
157
-				'length' => 20,
158
-				'default' => 0,
159
-			]);
160
-			$table->addColumn('name', 'string', [
161
-				'notnull' => false,
162
-				'length' => 250,
163
-			]);
164
-			$table->addColumn('mimetype', Type::BIGINT, [
165
-				'notnull' => true,
166
-				'length' => 20,
167
-				'default' => 0,
168
-			]);
169
-			$table->addColumn('mimepart', Type::BIGINT, [
170
-				'notnull' => true,
171
-				'length' => 20,
172
-				'default' => 0,
173
-			]);
174
-			$table->addColumn('size', 'bigint', [
175
-				'notnull' => true,
176
-				'length' => 8,
177
-				'default' => 0,
178
-			]);
179
-			$table->addColumn('mtime', 'integer', [
180
-				'notnull' => true,
181
-				'length' => 4,
182
-				'default' => 0,
183
-			]);
184
-			$table->addColumn('storage_mtime', 'integer', [
185
-				'notnull' => true,
186
-				'length' => 4,
187
-				'default' => 0,
188
-			]);
189
-			$table->addColumn('encrypted', 'integer', [
190
-				'notnull' => true,
191
-				'length' => 4,
192
-				'default' => 0,
193
-			]);
194
-			$table->addColumn('unencrypted_size', 'bigint', [
195
-				'notnull' => true,
196
-				'length' => 8,
197
-				'default' => 0,
198
-			]);
199
-			$table->addColumn('etag', 'string', [
200
-				'notnull' => false,
201
-				'length' => 40,
202
-			]);
203
-			$table->addColumn('permissions', 'integer', [
204
-				'notnull' => false,
205
-				'length' => 4,
206
-				'default' => 0,
207
-			]);
208
-			$table->addColumn('checksum', 'string', [
209
-				'notnull' => false,
210
-				'length' => 255,
211
-			]);
212
-			$table->setPrimaryKey(['fileid']);
213
-			$table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash');
214
-			$table->addIndex(['parent', 'name'], 'fs_parent_name_hash');
215
-			$table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype');
216
-			$table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart');
217
-			$table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
218
-		}
219
-
220
-		if (!$schema->hasTable('group_user')) {
221
-			$table = $schema->createTable('group_user');
222
-			$table->addColumn('gid', 'string', [
223
-				'notnull' => true,
224
-				'length' => 64,
225
-				'default' => '',
226
-			]);
227
-			$table->addColumn('uid', 'string', [
228
-				'notnull' => true,
229
-				'length' => 64,
230
-				'default' => '',
231
-			]);
232
-			$table->setPrimaryKey(['gid', 'uid']);
233
-			$table->addIndex(['uid'], 'gu_uid_index');
234
-		}
235
-
236
-		if (!$schema->hasTable('group_admin')) {
237
-			$table = $schema->createTable('group_admin');
238
-			$table->addColumn('gid', 'string', [
239
-				'notnull' => true,
240
-				'length' => 64,
241
-				'default' => '',
242
-			]);
243
-			$table->addColumn('uid', 'string', [
244
-				'notnull' => true,
245
-				'length' => 64,
246
-				'default' => '',
247
-			]);
248
-			$table->setPrimaryKey(['gid', 'uid']);
249
-			$table->addIndex(['uid'], 'group_admin_uid');
250
-		}
251
-
252
-		if (!$schema->hasTable('groups')) {
253
-			$table = $schema->createTable('groups');
254
-			$table->addColumn('gid', 'string', [
255
-				'notnull' => true,
256
-				'length' => 64,
257
-				'default' => '',
258
-			]);
259
-			$table->setPrimaryKey(['gid']);
260
-		}
261
-
262
-		if (!$schema->hasTable('preferences')) {
263
-			$table = $schema->createTable('preferences');
264
-			$table->addColumn('userid', 'string', [
265
-				'notnull' => true,
266
-				'length' => 64,
267
-				'default' => '',
268
-			]);
269
-			$table->addColumn('appid', 'string', [
270
-				'notnull' => true,
271
-				'length' => 32,
272
-				'default' => '',
273
-			]);
274
-			$table->addColumn('configkey', 'string', [
275
-				'notnull' => true,
276
-				'length' => 64,
277
-				'default' => '',
278
-			]);
279
-			$table->addColumn('configvalue', 'text', [
280
-				'notnull' => false,
281
-			]);
282
-			$table->setPrimaryKey(['userid', 'appid', 'configkey']);
283
-		}
284
-
285
-		if (!$schema->hasTable('properties')) {
286
-			$table = $schema->createTable('properties');
287
-			$table->addColumn('id', 'integer', [
288
-				'autoincrement' => true,
289
-				'notnull' => true,
290
-				'length' => 4,
291
-			]);
292
-			$table->addColumn('userid', 'string', [
293
-				'notnull' => true,
294
-				'length' => 64,
295
-				'default' => '',
296
-			]);
297
-			$table->addColumn('propertypath', 'string', [
298
-				'notnull' => true,
299
-				'length' => 255,
300
-				'default' => '',
301
-			]);
302
-			$table->addColumn('propertyname', 'string', [
303
-				'notnull' => true,
304
-				'length' => 255,
305
-				'default' => '',
306
-			]);
307
-			$table->addColumn('propertyvalue', 'text', [
308
-				'notnull' => true,
309
-			]);
310
-			$table->setPrimaryKey(['id']);
311
-			$table->addIndex(['userid'], 'property_index');
312
-		}
313
-
314
-		if (!$schema->hasTable('share')) {
315
-			$table = $schema->createTable('share');
316
-			$table->addColumn('id', 'integer', [
317
-				'autoincrement' => true,
318
-				'notnull' => true,
319
-				'length' => 4,
320
-			]);
321
-			$table->addColumn('share_type', 'smallint', [
322
-				'notnull' => true,
323
-				'length' => 1,
324
-				'default' => 0,
325
-			]);
326
-			$table->addColumn('share_with', 'string', [
327
-				'notnull' => false,
328
-				'length' => 255,
329
-			]);
330
-			$table->addColumn('password', 'string', [
331
-				'notnull' => false,
332
-				'length' => 255,
333
-			]);
334
-			$table->addColumn('uid_owner', 'string', [
335
-				'notnull' => true,
336
-				'length' => 64,
337
-				'default' => '',
338
-			]);
339
-			$table->addColumn('uid_initiator', 'string', [
340
-				'notnull' => false,
341
-				'length' => 64,
342
-			]);
343
-			$table->addColumn('parent', 'integer', [
344
-				'notnull' => false,
345
-				'length' => 4,
346
-			]);
347
-			$table->addColumn('item_type', 'string', [
348
-				'notnull' => true,
349
-				'length' => 64,
350
-				'default' => '',
351
-			]);
352
-			$table->addColumn('item_source', 'string', [
353
-				'notnull' => false,
354
-				'length' => 255,
355
-			]);
356
-			$table->addColumn('item_target', 'string', [
357
-				'notnull' => false,
358
-				'length' => 255,
359
-			]);
360
-			$table->addColumn('file_source', 'integer', [
361
-				'notnull' => false,
362
-				'length' => 4,
363
-			]);
364
-			$table->addColumn('file_target', 'string', [
365
-				'notnull' => false,
366
-				'length' => 512,
367
-			]);
368
-			$table->addColumn('permissions', 'smallint', [
369
-				'notnull' => true,
370
-				'length' => 1,
371
-				'default' => 0,
372
-			]);
373
-			$table->addColumn('stime', 'bigint', [
374
-				'notnull' => true,
375
-				'length' => 8,
376
-				'default' => 0,
377
-			]);
378
-			$table->addColumn('accepted', 'smallint', [
379
-				'notnull' => true,
380
-				'length' => 1,
381
-				'default' => 0,
382
-			]);
383
-			$table->addColumn('expiration', 'datetime', [
384
-				'notnull' => false,
385
-			]);
386
-			$table->addColumn('token', 'string', [
387
-				'notnull' => false,
388
-				'length' => 32,
389
-			]);
390
-			$table->addColumn('mail_send', 'smallint', [
391
-				'notnull' => true,
392
-				'length' => 1,
393
-				'default' => 0,
394
-			]);
395
-			$table->addColumn('share_name', 'string', [
396
-				'notnull' => false,
397
-				'length' => 64,
398
-			]);
399
-			$table->setPrimaryKey(['id']);
400
-			$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
401
-			$table->addIndex(['file_source'], 'file_source_index');
402
-			$table->addIndex(['token'], 'token_index');
403
-			$table->addIndex(['share_with'], 'share_with_index');
404
-			$table->addIndex(['parent'], 'parent_index');
405
-		}
406
-
407
-		if (!$schema->hasTable('jobs')) {
408
-			$table = $schema->createTable('jobs');
409
-			$table->addColumn('id', 'integer', [
410
-				'autoincrement' => true,
411
-				'notnull' => true,
412
-				'length' => 4,
413
-				'unsigned' => true,
414
-			]);
415
-			$table->addColumn('class', 'string', [
416
-				'notnull' => true,
417
-				'length' => 255,
418
-				'default' => '',
419
-			]);
420
-			$table->addColumn('argument', 'string', [
421
-				'notnull' => true,
422
-				'length' => 4000,
423
-				'default' => '',
424
-			]);
425
-			$table->addColumn('last_run', 'integer', [
426
-				'notnull' => false,
427
-				'default' => 0,
428
-			]);
429
-			$table->addColumn('last_checked', 'integer', [
430
-				'notnull' => false,
431
-				'default' => 0,
432
-			]);
433
-			$table->addColumn('reserved_at', 'integer', [
434
-				'notnull' => false,
435
-				'default' => 0,
436
-			]);
437
-			$table->addColumn('execution_duration', 'integer', [
438
-				'notnull' => true,
439
-				'default' => 0,
440
-			]);
441
-			$table->setPrimaryKey(['id']);
442
-			$table->addIndex(['class'], 'job_class_index');
443
-		}
444
-
445
-		if (!$schema->hasTable('users')) {
446
-			$table = $schema->createTable('users');
447
-			$table->addColumn('uid', 'string', [
448
-				'notnull' => true,
449
-				'length' => 64,
450
-				'default' => '',
451
-			]);
452
-			$table->addColumn('displayname', 'string', [
453
-				'notnull' => false,
454
-				'length' => 64,
455
-			]);
456
-			$table->addColumn('password', 'string', [
457
-				'notnull' => true,
458
-				'length' => 255,
459
-				'default' => '',
460
-			]);
461
-			$table->setPrimaryKey(['uid']);
462
-		}
463
-
464
-		if (!$schema->hasTable('authtoken')) {
465
-			$table = $schema->createTable('authtoken');
466
-			$table->addColumn('id', 'integer', [
467
-				'autoincrement' => true,
468
-				'notnull' => true,
469
-				'length' => 4,
470
-				'unsigned' => true,
471
-			]);
472
-			$table->addColumn('uid', 'string', [
473
-				'notnull' => true,
474
-				'length' => 64,
475
-				'default' => '',
476
-			]);
477
-			$table->addColumn('login_name', 'string', [
478
-				'notnull' => true,
479
-				'length' => 64,
480
-				'default' => '',
481
-			]);
482
-			$table->addColumn('password', 'text', [
483
-				'notnull' => false,
484
-			]);
485
-			$table->addColumn('name', 'text', [
486
-				'notnull' => true,
487
-				'default' => '',
488
-			]);
489
-			$table->addColumn('token', 'string', [
490
-				'notnull' => true,
491
-				'length' => 200,
492
-				'default' => '',
493
-			]);
494
-			$table->addColumn('type', 'smallint', [
495
-				'notnull' => true,
496
-				'length' => 2,
497
-				'default' => 0,
498
-				'unsigned' => true,
499
-			]);
500
-			$table->addColumn('remember', 'smallint', [
501
-				'notnull' => true,
502
-				'length' => 1,
503
-				'default' => 0,
504
-				'unsigned' => true,
505
-			]);
506
-			$table->addColumn('last_activity', 'integer', [
507
-				'notnull' => true,
508
-				'length' => 4,
509
-				'default' => 0,
510
-				'unsigned' => true,
511
-			]);
512
-			$table->addColumn('last_check', 'integer', [
513
-				'notnull' => true,
514
-				'length' => 4,
515
-				'default' => 0,
516
-				'unsigned' => true,
517
-			]);
518
-			$table->addColumn('scope', 'text', [
519
-				'notnull' => false,
520
-			]);
521
-			$table->setPrimaryKey(['id']);
522
-			$table->addUniqueIndex(['token'], 'authtoken_token_index');
523
-			$table->addIndex(['last_activity'], 'authtoken_last_activity_index');
524
-		}
525
-
526
-		if (!$schema->hasTable('bruteforce_attempts')) {
527
-			$table = $schema->createTable('bruteforce_attempts');
528
-			$table->addColumn('id', 'integer', [
529
-				'autoincrement' => true,
530
-				'notnull' => true,
531
-				'length' => 4,
532
-				'unsigned' => true,
533
-			]);
534
-			$table->addColumn('action', 'string', [
535
-				'notnull' => true,
536
-				'length' => 64,
537
-				'default' => '',
538
-			]);
539
-			$table->addColumn('occurred', 'integer', [
540
-				'notnull' => true,
541
-				'length' => 4,
542
-				'default' => 0,
543
-				'unsigned' => true,
544
-			]);
545
-			$table->addColumn('ip', 'string', [
546
-				'notnull' => true,
547
-				'length' => 255,
548
-				'default' => '',
549
-			]);
550
-			$table->addColumn('subnet', 'string', [
551
-				'notnull' => true,
552
-				'length' => 255,
553
-				'default' => '',
554
-			]);
555
-			$table->addColumn('metadata', 'string', [
556
-				'notnull' => true,
557
-				'length' => 255,
558
-				'default' => '',
559
-			]);
560
-			$table->setPrimaryKey(['id']);
561
-			$table->addIndex(['ip'], 'bruteforce_attempts_ip');
562
-			$table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
563
-		}
564
-
565
-		if (!$schema->hasTable('vcategory')) {
566
-			$table = $schema->createTable('vcategory');
567
-			$table->addColumn('id', 'integer', [
568
-				'autoincrement' => true,
569
-				'notnull' => true,
570
-				'length' => 4,
571
-				'unsigned' => true,
572
-			]);
573
-			$table->addColumn('uid', 'string', [
574
-				'notnull' => true,
575
-				'length' => 64,
576
-				'default' => '',
577
-			]);
578
-			$table->addColumn('type', 'string', [
579
-				'notnull' => true,
580
-				'length' => 64,
581
-				'default' => '',
582
-			]);
583
-			$table->addColumn('category', 'string', [
584
-				'notnull' => true,
585
-				'length' => 255,
586
-				'default' => '',
587
-			]);
588
-			$table->setPrimaryKey(['id']);
589
-			$table->addIndex(['uid'], 'uid_index');
590
-			$table->addIndex(['type'], 'type_index');
591
-			$table->addIndex(['category'], 'category_index');
592
-		}
593
-
594
-		if (!$schema->hasTable('vcategory_to_object')) {
595
-			$table = $schema->createTable('vcategory_to_object');
596
-			$table->addColumn('objid', 'integer', [
597
-				'notnull' => true,
598
-				'length' => 4,
599
-				'default' => 0,
600
-				'unsigned' => true,
601
-			]);
602
-			$table->addColumn('categoryid', 'integer', [
603
-				'notnull' => true,
604
-				'length' => 4,
605
-				'default' => 0,
606
-				'unsigned' => true,
607
-			]);
608
-			$table->addColumn('type', 'string', [
609
-				'notnull' => true,
610
-				'length' => 64,
611
-				'default' => '',
612
-			]);
613
-			$table->setPrimaryKey(['categoryid', 'objid', 'type']);
614
-			$table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
615
-		}
616
-
617
-		if (!$schema->hasTable('systemtag')) {
618
-			$table = $schema->createTable('systemtag');
619
-			$table->addColumn('id', 'integer', [
620
-				'autoincrement' => true,
621
-				'notnull' => true,
622
-				'length' => 4,
623
-				'unsigned' => true,
624
-			]);
625
-			$table->addColumn('name', 'string', [
626
-				'notnull' => true,
627
-				'length' => 64,
628
-				'default' => '',
629
-			]);
630
-			$table->addColumn('visibility', 'smallint', [
631
-				'notnull' => true,
632
-				'length' => 1,
633
-				'default' => 1,
634
-			]);
635
-			$table->addColumn('editable', 'smallint', [
636
-				'notnull' => true,
637
-				'length' => 1,
638
-				'default' => 1,
639
-			]);
640
-			$table->setPrimaryKey(['id']);
641
-			$table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
642
-		}
643
-
644
-		if (!$schema->hasTable('systemtag_object_mapping')) {
645
-			$table = $schema->createTable('systemtag_object_mapping');
646
-			$table->addColumn('objectid', 'string', [
647
-				'notnull' => true,
648
-				'length' => 64,
649
-				'default' => '',
650
-			]);
651
-			$table->addColumn('objecttype', 'string', [
652
-				'notnull' => true,
653
-				'length' => 64,
654
-				'default' => '',
655
-			]);
656
-			$table->addColumn('systemtagid', 'integer', [
657
-				'notnull' => true,
658
-				'length' => 4,
659
-				'default' => 0,
660
-				'unsigned' => true,
661
-			]);
662
-			$table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
663
-		}
664
-
665
-		if (!$schema->hasTable('systemtag_group')) {
666
-			$table = $schema->createTable('systemtag_group');
667
-			$table->addColumn('systemtagid', 'integer', [
668
-				'notnull' => true,
669
-				'length' => 4,
670
-				'default' => 0,
671
-				'unsigned' => true,
672
-			]);
673
-			$table->addColumn('gid', 'string', [
674
-				'notnull' => true,
675
-			]);
676
-			$table->setPrimaryKey(['gid', 'systemtagid']);
677
-		}
678
-
679
-		if (!$schema->hasTable('file_locks')) {
680
-			$table = $schema->createTable('file_locks');
681
-			$table->addColumn('id', 'integer', [
682
-				'autoincrement' => true,
683
-				'notnull' => true,
684
-				'length' => 4,
685
-				'unsigned' => true,
686
-			]);
687
-			$table->addColumn('lock', 'integer', [
688
-				'notnull' => true,
689
-				'length' => 4,
690
-				'default' => 0,
691
-			]);
692
-			$table->addColumn('key', 'string', [
693
-				'notnull' => true,
694
-				'length' => 64,
695
-			]);
696
-			$table->addColumn('ttl', 'integer', [
697
-				'notnull' => true,
698
-				'length' => 4,
699
-				'default' => -1,
700
-			]);
701
-			$table->setPrimaryKey(['id']);
702
-			$table->addUniqueIndex(['key'], 'lock_key_index');
703
-			$table->addIndex(['ttl'], 'lock_ttl_index');
704
-		}
705
-
706
-		if (!$schema->hasTable('comments')) {
707
-			$table = $schema->createTable('comments');
708
-			$table->addColumn('id', 'integer', [
709
-				'autoincrement' => true,
710
-				'notnull' => true,
711
-				'length' => 4,
712
-				'unsigned' => true,
713
-			]);
714
-			$table->addColumn('parent_id', 'integer', [
715
-				'notnull' => true,
716
-				'length' => 4,
717
-				'default' => 0,
718
-				'unsigned' => true,
719
-			]);
720
-			$table->addColumn('topmost_parent_id', 'integer', [
721
-				'notnull' => true,
722
-				'length' => 4,
723
-				'default' => 0,
724
-				'unsigned' => true,
725
-			]);
726
-			$table->addColumn('children_count', 'integer', [
727
-				'notnull' => true,
728
-				'length' => 4,
729
-				'default' => 0,
730
-				'unsigned' => true,
731
-			]);
732
-			$table->addColumn('actor_type', 'string', [
733
-				'notnull' => true,
734
-				'length' => 64,
735
-				'default' => '',
736
-			]);
737
-			$table->addColumn('actor_id', 'string', [
738
-				'notnull' => true,
739
-				'length' => 64,
740
-				'default' => '',
741
-			]);
742
-			$table->addColumn('message', 'text', [
743
-				'notnull' => false,
744
-			]);
745
-			$table->addColumn('verb', 'string', [
746
-				'notnull' => false,
747
-				'length' => 64,
748
-			]);
749
-			$table->addColumn('creation_timestamp', 'datetime', [
750
-				'notnull' => false,
751
-			]);
752
-			$table->addColumn('latest_child_timestamp', 'datetime', [
753
-				'notnull' => false,
754
-			]);
755
-			$table->addColumn('object_type', 'string', [
756
-				'notnull' => true,
757
-				'length' => 64,
758
-				'default' => '',
759
-			]);
760
-			$table->addColumn('object_id', 'string', [
761
-				'notnull' => true,
762
-				'length' => 64,
763
-				'default' => '',
764
-			]);
765
-			$table->setPrimaryKey(['id']);
766
-			$table->addIndex(['parent_id'], 'comments_parent_id_index');
767
-			$table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
768
-			$table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
769
-			$table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
770
-		}
771
-
772
-		if (!$schema->hasTable('comments_read_markers')) {
773
-			$table = $schema->createTable('comments_read_markers');
774
-			$table->addColumn('user_id', 'string', [
775
-				'notnull' => true,
776
-				'length' => 64,
777
-				'default' => '',
778
-			]);
779
-			$table->addColumn('marker_datetime', 'datetime', [
780
-				'notnull' => false,
781
-			]);
782
-			$table->addColumn('object_type', 'string', [
783
-				'notnull' => true,
784
-				'length' => 64,
785
-				'default' => '',
786
-			]);
787
-			$table->addColumn('object_id', 'string', [
788
-				'notnull' => true,
789
-				'length' => 64,
790
-				'default' => '',
791
-			]);
792
-			$table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
793
-			$table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
794
-		}
795
-
796
-		if (!$schema->hasTable('credentials')) {
797
-			$table = $schema->createTable('credentials');
798
-			$table->addColumn('user', 'string', [
799
-				'notnull' => true,
800
-				'length' => 64,
801
-			]);
802
-			$table->addColumn('identifier', 'string', [
803
-				'notnull' => true,
804
-				'length' => 64,
805
-			]);
806
-			$table->addColumn('credentials', 'text', [
807
-				'notnull' => false,
808
-			]);
809
-			$table->setPrimaryKey(['user', 'identifier']);
810
-			$table->addIndex(['user'], 'credentials_user');
811
-		}
812
-
813
-		if (!$schema->hasTable('admin_sections')) {
814
-			$table = $schema->createTable('admin_sections');
815
-			$table->addColumn('id', 'string', [
816
-				'notnull' => true,
817
-				'length' => 64,
818
-			]);
819
-			$table->addColumn('class', 'string', [
820
-				'notnull' => true,
821
-				'length' => 255,
822
-				'default' => '',
823
-			]);
824
-			$table->addColumn('priority', 'smallint', [
825
-				'notnull' => true,
826
-				'length' => 1,
827
-				'default' => 0,
828
-			]);
829
-			$table->setPrimaryKey(['id']);
830
-			$table->addUniqueIndex(['class'], 'admin_sections_class');
831
-		}
832
-
833
-		if (!$schema->hasTable('admin_settings')) {
834
-			$table = $schema->createTable('admin_settings');
835
-			$table->addColumn('id', 'integer', [
836
-				'autoincrement' => true,
837
-				'notnull' => true,
838
-				'length' => 4,
839
-			]);
840
-			$table->addColumn('class', 'string', [
841
-				'notnull' => true,
842
-				'length' => 255,
843
-				'default' => '',
844
-			]);
845
-			$table->addColumn('section', 'string', [
846
-				'notnull' => false,
847
-				'length' => 64,
848
-			]);
849
-			$table->addColumn('priority', 'smallint', [
850
-				'notnull' => true,
851
-				'length' => 1,
852
-				'default' => 0,
853
-			]);
854
-			$table->setPrimaryKey(['id']);
855
-			$table->addUniqueIndex(['class'], 'admin_settings_class');
856
-			$table->addIndex(['section'], 'admin_settings_section');
857
-		}
858
-
859
-		if (!$schema->hasTable('personal_sections')) {
860
-			$table = $schema->createTable('personal_sections');
861
-			$table->addColumn('id', 'string', [
862
-				'notnull' => true,
863
-				'length' => 64,
864
-			]);
865
-			$table->addColumn('class', 'string', [
866
-				'notnull' => true,
867
-				'length' => 255,
868
-				'default' => '',
869
-			]);
870
-			$table->addColumn('priority', 'smallint', [
871
-				'notnull' => true,
872
-				'length' => 1,
873
-				'default' => 0,
874
-			]);
875
-			$table->setPrimaryKey(['id']);
876
-			$table->addUniqueIndex(['class'], 'personal_sections_class');
877
-		}
878
-
879
-		if (!$schema->hasTable('personal_settings')) {
880
-			$table = $schema->createTable('personal_settings');
881
-			$table->addColumn('id', 'integer', [
882
-				'autoincrement' => true,
883
-				'notnull' => true,
884
-				'length' => 4,
885
-			]);
886
-			$table->addColumn('class', 'string', [
887
-				'notnull' => true,
888
-				'length' => 255,
889
-				'default' => '',
890
-			]);
891
-			$table->addColumn('section', 'string', [
892
-				'notnull' => false,
893
-				'length' => 64,
894
-			]);
895
-			$table->addColumn('priority', 'smallint', [
896
-				'notnull' => true,
897
-				'length' => 1,
898
-				'default' => 0,
899
-			]);
900
-			$table->setPrimaryKey(['id']);
901
-			$table->addUniqueIndex(['class'], 'personal_settings_class');
902
-			$table->addIndex(['section'], 'personal_settings_section');
903
-		}
904
-
905
-		if (!$schema->hasTable('accounts')) {
906
-			$table = $schema->createTable('accounts');
907
-			$table->addColumn('uid', 'string', [
908
-				'notnull' => true,
909
-				'length' => 64,
910
-				'default' => '',
911
-			]);
912
-			$table->addColumn('data', 'text', [
913
-				'notnull' => true,
914
-				'default' => '',
915
-			]);
916
-			$table->setPrimaryKey(['uid']);
917
-		}
918
-		return $schema;
919
-	}
33
+    /**
34
+     * @param IOutput $output
35
+     * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
36
+     * @param array $options
37
+     * @return null|ISchemaWrapper
38
+     * @since 13.0.0
39
+     */
40
+    public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
41
+        /** @var ISchemaWrapper $schema */
42
+        $schema = $schemaClosure();
43
+
44
+        if (!$schema->hasTable('appconfig')) {
45
+            $table = $schema->createTable('appconfig');
46
+            $table->addColumn('appid', 'string', [
47
+                'notnull' => true,
48
+                'length' => 32,
49
+                'default' => '',
50
+            ]);
51
+            $table->addColumn('configkey', 'string', [
52
+                'notnull' => true,
53
+                'length' => 64,
54
+                'default' => '',
55
+            ]);
56
+            $table->addColumn('configvalue', 'text', [
57
+                'notnull' => false,
58
+            ]);
59
+            $table->setPrimaryKey(['appid', 'configkey']);
60
+            $table->addIndex(['configkey'], 'appconfig_config_key_index');
61
+            $table->addIndex(['appid'], 'appconfig_appid_key');
62
+        }
63
+
64
+        if (!$schema->hasTable('storages')) {
65
+            $table = $schema->createTable('storages');
66
+            $table->addColumn('id', 'string', [
67
+                'notnull' => false,
68
+                'length' => 64,
69
+            ]);
70
+            $table->addColumn('numeric_id', Type::BIGINT, [
71
+                'autoincrement' => true,
72
+                'notnull' => true,
73
+                'length' => 20,
74
+            ]);
75
+            $table->addColumn('available', 'integer', [
76
+                'notnull' => true,
77
+                'default' => 1,
78
+            ]);
79
+            $table->addColumn('last_checked', 'integer', [
80
+                'notnull' => false,
81
+            ]);
82
+            $table->setPrimaryKey(['numeric_id']);
83
+            $table->addUniqueIndex(['id'], 'storages_id_index');
84
+        }
85
+
86
+        if (!$schema->hasTable('mounts')) {
87
+            $table = $schema->createTable('mounts');
88
+            $table->addColumn('id', 'integer', [
89
+                'autoincrement' => true,
90
+                'notnull' => true,
91
+                'length' => 4,
92
+            ]);
93
+            $table->addColumn('storage_id', 'integer', [
94
+                'notnull' => true,
95
+            ]);
96
+            $table->addColumn('root_id', 'integer', [
97
+                'notnull' => true,
98
+            ]);
99
+            $table->addColumn('user_id', 'string', [
100
+                'notnull' => true,
101
+                'length' => 64,
102
+            ]);
103
+            $table->addColumn('mount_point', 'string', [
104
+                'notnull' => true,
105
+                'length' => 4000,
106
+            ]);
107
+            $table->addColumn('mount_id', 'integer', [
108
+                'notnull' => false,
109
+            ]);
110
+            $table->setPrimaryKey(['id']);
111
+            $table->addIndex(['user_id'], 'mounts_user_index');
112
+            $table->addIndex(['storage_id'], 'mounts_storage_index');
113
+            $table->addIndex(['root_id'], 'mounts_root_index');
114
+            $table->addIndex(['mount_id'], 'mounts_mount_id_index');
115
+            $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
116
+        }
117
+
118
+        if (!$schema->hasTable('mimetypes')) {
119
+            $table = $schema->createTable('mimetypes');
120
+            $table->addColumn('id', Type::BIGINT, [
121
+                'autoincrement' => true,
122
+                'notnull' => true,
123
+                'length' => 20,
124
+            ]);
125
+            $table->addColumn('mimetype', 'string', [
126
+                'notnull' => true,
127
+                'length' => 255,
128
+                'default' => '',
129
+            ]);
130
+            $table->setPrimaryKey(['id']);
131
+            $table->addUniqueIndex(['mimetype'], 'mimetype_id_index');
132
+        }
133
+
134
+        if (!$schema->hasTable('filecache')) {
135
+            $table = $schema->createTable('filecache');
136
+            $table->addColumn('fileid', Type::BIGINT, [
137
+                'autoincrement' => true,
138
+                'notnull' => true,
139
+                'length' => 20,
140
+            ]);
141
+            $table->addColumn('storage', Type::BIGINT, [
142
+                'notnull' => true,
143
+                'length' => 20,
144
+                'default' => 0,
145
+            ]);
146
+            $table->addColumn('path', 'string', [
147
+                'notnull' => false,
148
+                'length' => 4000,
149
+            ]);
150
+            $table->addColumn('path_hash', 'string', [
151
+                'notnull' => true,
152
+                'length' => 32,
153
+                'default' => '',
154
+            ]);
155
+            $table->addColumn('parent', Type::BIGINT, [
156
+                'notnull' => true,
157
+                'length' => 20,
158
+                'default' => 0,
159
+            ]);
160
+            $table->addColumn('name', 'string', [
161
+                'notnull' => false,
162
+                'length' => 250,
163
+            ]);
164
+            $table->addColumn('mimetype', Type::BIGINT, [
165
+                'notnull' => true,
166
+                'length' => 20,
167
+                'default' => 0,
168
+            ]);
169
+            $table->addColumn('mimepart', Type::BIGINT, [
170
+                'notnull' => true,
171
+                'length' => 20,
172
+                'default' => 0,
173
+            ]);
174
+            $table->addColumn('size', 'bigint', [
175
+                'notnull' => true,
176
+                'length' => 8,
177
+                'default' => 0,
178
+            ]);
179
+            $table->addColumn('mtime', 'integer', [
180
+                'notnull' => true,
181
+                'length' => 4,
182
+                'default' => 0,
183
+            ]);
184
+            $table->addColumn('storage_mtime', 'integer', [
185
+                'notnull' => true,
186
+                'length' => 4,
187
+                'default' => 0,
188
+            ]);
189
+            $table->addColumn('encrypted', 'integer', [
190
+                'notnull' => true,
191
+                'length' => 4,
192
+                'default' => 0,
193
+            ]);
194
+            $table->addColumn('unencrypted_size', 'bigint', [
195
+                'notnull' => true,
196
+                'length' => 8,
197
+                'default' => 0,
198
+            ]);
199
+            $table->addColumn('etag', 'string', [
200
+                'notnull' => false,
201
+                'length' => 40,
202
+            ]);
203
+            $table->addColumn('permissions', 'integer', [
204
+                'notnull' => false,
205
+                'length' => 4,
206
+                'default' => 0,
207
+            ]);
208
+            $table->addColumn('checksum', 'string', [
209
+                'notnull' => false,
210
+                'length' => 255,
211
+            ]);
212
+            $table->setPrimaryKey(['fileid']);
213
+            $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash');
214
+            $table->addIndex(['parent', 'name'], 'fs_parent_name_hash');
215
+            $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype');
216
+            $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart');
217
+            $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
218
+        }
219
+
220
+        if (!$schema->hasTable('group_user')) {
221
+            $table = $schema->createTable('group_user');
222
+            $table->addColumn('gid', 'string', [
223
+                'notnull' => true,
224
+                'length' => 64,
225
+                'default' => '',
226
+            ]);
227
+            $table->addColumn('uid', 'string', [
228
+                'notnull' => true,
229
+                'length' => 64,
230
+                'default' => '',
231
+            ]);
232
+            $table->setPrimaryKey(['gid', 'uid']);
233
+            $table->addIndex(['uid'], 'gu_uid_index');
234
+        }
235
+
236
+        if (!$schema->hasTable('group_admin')) {
237
+            $table = $schema->createTable('group_admin');
238
+            $table->addColumn('gid', 'string', [
239
+                'notnull' => true,
240
+                'length' => 64,
241
+                'default' => '',
242
+            ]);
243
+            $table->addColumn('uid', 'string', [
244
+                'notnull' => true,
245
+                'length' => 64,
246
+                'default' => '',
247
+            ]);
248
+            $table->setPrimaryKey(['gid', 'uid']);
249
+            $table->addIndex(['uid'], 'group_admin_uid');
250
+        }
251
+
252
+        if (!$schema->hasTable('groups')) {
253
+            $table = $schema->createTable('groups');
254
+            $table->addColumn('gid', 'string', [
255
+                'notnull' => true,
256
+                'length' => 64,
257
+                'default' => '',
258
+            ]);
259
+            $table->setPrimaryKey(['gid']);
260
+        }
261
+
262
+        if (!$schema->hasTable('preferences')) {
263
+            $table = $schema->createTable('preferences');
264
+            $table->addColumn('userid', 'string', [
265
+                'notnull' => true,
266
+                'length' => 64,
267
+                'default' => '',
268
+            ]);
269
+            $table->addColumn('appid', 'string', [
270
+                'notnull' => true,
271
+                'length' => 32,
272
+                'default' => '',
273
+            ]);
274
+            $table->addColumn('configkey', 'string', [
275
+                'notnull' => true,
276
+                'length' => 64,
277
+                'default' => '',
278
+            ]);
279
+            $table->addColumn('configvalue', 'text', [
280
+                'notnull' => false,
281
+            ]);
282
+            $table->setPrimaryKey(['userid', 'appid', 'configkey']);
283
+        }
284
+
285
+        if (!$schema->hasTable('properties')) {
286
+            $table = $schema->createTable('properties');
287
+            $table->addColumn('id', 'integer', [
288
+                'autoincrement' => true,
289
+                'notnull' => true,
290
+                'length' => 4,
291
+            ]);
292
+            $table->addColumn('userid', 'string', [
293
+                'notnull' => true,
294
+                'length' => 64,
295
+                'default' => '',
296
+            ]);
297
+            $table->addColumn('propertypath', 'string', [
298
+                'notnull' => true,
299
+                'length' => 255,
300
+                'default' => '',
301
+            ]);
302
+            $table->addColumn('propertyname', 'string', [
303
+                'notnull' => true,
304
+                'length' => 255,
305
+                'default' => '',
306
+            ]);
307
+            $table->addColumn('propertyvalue', 'text', [
308
+                'notnull' => true,
309
+            ]);
310
+            $table->setPrimaryKey(['id']);
311
+            $table->addIndex(['userid'], 'property_index');
312
+        }
313
+
314
+        if (!$schema->hasTable('share')) {
315
+            $table = $schema->createTable('share');
316
+            $table->addColumn('id', 'integer', [
317
+                'autoincrement' => true,
318
+                'notnull' => true,
319
+                'length' => 4,
320
+            ]);
321
+            $table->addColumn('share_type', 'smallint', [
322
+                'notnull' => true,
323
+                'length' => 1,
324
+                'default' => 0,
325
+            ]);
326
+            $table->addColumn('share_with', 'string', [
327
+                'notnull' => false,
328
+                'length' => 255,
329
+            ]);
330
+            $table->addColumn('password', 'string', [
331
+                'notnull' => false,
332
+                'length' => 255,
333
+            ]);
334
+            $table->addColumn('uid_owner', 'string', [
335
+                'notnull' => true,
336
+                'length' => 64,
337
+                'default' => '',
338
+            ]);
339
+            $table->addColumn('uid_initiator', 'string', [
340
+                'notnull' => false,
341
+                'length' => 64,
342
+            ]);
343
+            $table->addColumn('parent', 'integer', [
344
+                'notnull' => false,
345
+                'length' => 4,
346
+            ]);
347
+            $table->addColumn('item_type', 'string', [
348
+                'notnull' => true,
349
+                'length' => 64,
350
+                'default' => '',
351
+            ]);
352
+            $table->addColumn('item_source', 'string', [
353
+                'notnull' => false,
354
+                'length' => 255,
355
+            ]);
356
+            $table->addColumn('item_target', 'string', [
357
+                'notnull' => false,
358
+                'length' => 255,
359
+            ]);
360
+            $table->addColumn('file_source', 'integer', [
361
+                'notnull' => false,
362
+                'length' => 4,
363
+            ]);
364
+            $table->addColumn('file_target', 'string', [
365
+                'notnull' => false,
366
+                'length' => 512,
367
+            ]);
368
+            $table->addColumn('permissions', 'smallint', [
369
+                'notnull' => true,
370
+                'length' => 1,
371
+                'default' => 0,
372
+            ]);
373
+            $table->addColumn('stime', 'bigint', [
374
+                'notnull' => true,
375
+                'length' => 8,
376
+                'default' => 0,
377
+            ]);
378
+            $table->addColumn('accepted', 'smallint', [
379
+                'notnull' => true,
380
+                'length' => 1,
381
+                'default' => 0,
382
+            ]);
383
+            $table->addColumn('expiration', 'datetime', [
384
+                'notnull' => false,
385
+            ]);
386
+            $table->addColumn('token', 'string', [
387
+                'notnull' => false,
388
+                'length' => 32,
389
+            ]);
390
+            $table->addColumn('mail_send', 'smallint', [
391
+                'notnull' => true,
392
+                'length' => 1,
393
+                'default' => 0,
394
+            ]);
395
+            $table->addColumn('share_name', 'string', [
396
+                'notnull' => false,
397
+                'length' => 64,
398
+            ]);
399
+            $table->setPrimaryKey(['id']);
400
+            $table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
401
+            $table->addIndex(['file_source'], 'file_source_index');
402
+            $table->addIndex(['token'], 'token_index');
403
+            $table->addIndex(['share_with'], 'share_with_index');
404
+            $table->addIndex(['parent'], 'parent_index');
405
+        }
406
+
407
+        if (!$schema->hasTable('jobs')) {
408
+            $table = $schema->createTable('jobs');
409
+            $table->addColumn('id', 'integer', [
410
+                'autoincrement' => true,
411
+                'notnull' => true,
412
+                'length' => 4,
413
+                'unsigned' => true,
414
+            ]);
415
+            $table->addColumn('class', 'string', [
416
+                'notnull' => true,
417
+                'length' => 255,
418
+                'default' => '',
419
+            ]);
420
+            $table->addColumn('argument', 'string', [
421
+                'notnull' => true,
422
+                'length' => 4000,
423
+                'default' => '',
424
+            ]);
425
+            $table->addColumn('last_run', 'integer', [
426
+                'notnull' => false,
427
+                'default' => 0,
428
+            ]);
429
+            $table->addColumn('last_checked', 'integer', [
430
+                'notnull' => false,
431
+                'default' => 0,
432
+            ]);
433
+            $table->addColumn('reserved_at', 'integer', [
434
+                'notnull' => false,
435
+                'default' => 0,
436
+            ]);
437
+            $table->addColumn('execution_duration', 'integer', [
438
+                'notnull' => true,
439
+                'default' => 0,
440
+            ]);
441
+            $table->setPrimaryKey(['id']);
442
+            $table->addIndex(['class'], 'job_class_index');
443
+        }
444
+
445
+        if (!$schema->hasTable('users')) {
446
+            $table = $schema->createTable('users');
447
+            $table->addColumn('uid', 'string', [
448
+                'notnull' => true,
449
+                'length' => 64,
450
+                'default' => '',
451
+            ]);
452
+            $table->addColumn('displayname', 'string', [
453
+                'notnull' => false,
454
+                'length' => 64,
455
+            ]);
456
+            $table->addColumn('password', 'string', [
457
+                'notnull' => true,
458
+                'length' => 255,
459
+                'default' => '',
460
+            ]);
461
+            $table->setPrimaryKey(['uid']);
462
+        }
463
+
464
+        if (!$schema->hasTable('authtoken')) {
465
+            $table = $schema->createTable('authtoken');
466
+            $table->addColumn('id', 'integer', [
467
+                'autoincrement' => true,
468
+                'notnull' => true,
469
+                'length' => 4,
470
+                'unsigned' => true,
471
+            ]);
472
+            $table->addColumn('uid', 'string', [
473
+                'notnull' => true,
474
+                'length' => 64,
475
+                'default' => '',
476
+            ]);
477
+            $table->addColumn('login_name', 'string', [
478
+                'notnull' => true,
479
+                'length' => 64,
480
+                'default' => '',
481
+            ]);
482
+            $table->addColumn('password', 'text', [
483
+                'notnull' => false,
484
+            ]);
485
+            $table->addColumn('name', 'text', [
486
+                'notnull' => true,
487
+                'default' => '',
488
+            ]);
489
+            $table->addColumn('token', 'string', [
490
+                'notnull' => true,
491
+                'length' => 200,
492
+                'default' => '',
493
+            ]);
494
+            $table->addColumn('type', 'smallint', [
495
+                'notnull' => true,
496
+                'length' => 2,
497
+                'default' => 0,
498
+                'unsigned' => true,
499
+            ]);
500
+            $table->addColumn('remember', 'smallint', [
501
+                'notnull' => true,
502
+                'length' => 1,
503
+                'default' => 0,
504
+                'unsigned' => true,
505
+            ]);
506
+            $table->addColumn('last_activity', 'integer', [
507
+                'notnull' => true,
508
+                'length' => 4,
509
+                'default' => 0,
510
+                'unsigned' => true,
511
+            ]);
512
+            $table->addColumn('last_check', 'integer', [
513
+                'notnull' => true,
514
+                'length' => 4,
515
+                'default' => 0,
516
+                'unsigned' => true,
517
+            ]);
518
+            $table->addColumn('scope', 'text', [
519
+                'notnull' => false,
520
+            ]);
521
+            $table->setPrimaryKey(['id']);
522
+            $table->addUniqueIndex(['token'], 'authtoken_token_index');
523
+            $table->addIndex(['last_activity'], 'authtoken_last_activity_index');
524
+        }
525
+
526
+        if (!$schema->hasTable('bruteforce_attempts')) {
527
+            $table = $schema->createTable('bruteforce_attempts');
528
+            $table->addColumn('id', 'integer', [
529
+                'autoincrement' => true,
530
+                'notnull' => true,
531
+                'length' => 4,
532
+                'unsigned' => true,
533
+            ]);
534
+            $table->addColumn('action', 'string', [
535
+                'notnull' => true,
536
+                'length' => 64,
537
+                'default' => '',
538
+            ]);
539
+            $table->addColumn('occurred', 'integer', [
540
+                'notnull' => true,
541
+                'length' => 4,
542
+                'default' => 0,
543
+                'unsigned' => true,
544
+            ]);
545
+            $table->addColumn('ip', 'string', [
546
+                'notnull' => true,
547
+                'length' => 255,
548
+                'default' => '',
549
+            ]);
550
+            $table->addColumn('subnet', 'string', [
551
+                'notnull' => true,
552
+                'length' => 255,
553
+                'default' => '',
554
+            ]);
555
+            $table->addColumn('metadata', 'string', [
556
+                'notnull' => true,
557
+                'length' => 255,
558
+                'default' => '',
559
+            ]);
560
+            $table->setPrimaryKey(['id']);
561
+            $table->addIndex(['ip'], 'bruteforce_attempts_ip');
562
+            $table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
563
+        }
564
+
565
+        if (!$schema->hasTable('vcategory')) {
566
+            $table = $schema->createTable('vcategory');
567
+            $table->addColumn('id', 'integer', [
568
+                'autoincrement' => true,
569
+                'notnull' => true,
570
+                'length' => 4,
571
+                'unsigned' => true,
572
+            ]);
573
+            $table->addColumn('uid', 'string', [
574
+                'notnull' => true,
575
+                'length' => 64,
576
+                'default' => '',
577
+            ]);
578
+            $table->addColumn('type', 'string', [
579
+                'notnull' => true,
580
+                'length' => 64,
581
+                'default' => '',
582
+            ]);
583
+            $table->addColumn('category', 'string', [
584
+                'notnull' => true,
585
+                'length' => 255,
586
+                'default' => '',
587
+            ]);
588
+            $table->setPrimaryKey(['id']);
589
+            $table->addIndex(['uid'], 'uid_index');
590
+            $table->addIndex(['type'], 'type_index');
591
+            $table->addIndex(['category'], 'category_index');
592
+        }
593
+
594
+        if (!$schema->hasTable('vcategory_to_object')) {
595
+            $table = $schema->createTable('vcategory_to_object');
596
+            $table->addColumn('objid', 'integer', [
597
+                'notnull' => true,
598
+                'length' => 4,
599
+                'default' => 0,
600
+                'unsigned' => true,
601
+            ]);
602
+            $table->addColumn('categoryid', 'integer', [
603
+                'notnull' => true,
604
+                'length' => 4,
605
+                'default' => 0,
606
+                'unsigned' => true,
607
+            ]);
608
+            $table->addColumn('type', 'string', [
609
+                'notnull' => true,
610
+                'length' => 64,
611
+                'default' => '',
612
+            ]);
613
+            $table->setPrimaryKey(['categoryid', 'objid', 'type']);
614
+            $table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
615
+        }
616
+
617
+        if (!$schema->hasTable('systemtag')) {
618
+            $table = $schema->createTable('systemtag');
619
+            $table->addColumn('id', 'integer', [
620
+                'autoincrement' => true,
621
+                'notnull' => true,
622
+                'length' => 4,
623
+                'unsigned' => true,
624
+            ]);
625
+            $table->addColumn('name', 'string', [
626
+                'notnull' => true,
627
+                'length' => 64,
628
+                'default' => '',
629
+            ]);
630
+            $table->addColumn('visibility', 'smallint', [
631
+                'notnull' => true,
632
+                'length' => 1,
633
+                'default' => 1,
634
+            ]);
635
+            $table->addColumn('editable', 'smallint', [
636
+                'notnull' => true,
637
+                'length' => 1,
638
+                'default' => 1,
639
+            ]);
640
+            $table->setPrimaryKey(['id']);
641
+            $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
642
+        }
643
+
644
+        if (!$schema->hasTable('systemtag_object_mapping')) {
645
+            $table = $schema->createTable('systemtag_object_mapping');
646
+            $table->addColumn('objectid', 'string', [
647
+                'notnull' => true,
648
+                'length' => 64,
649
+                'default' => '',
650
+            ]);
651
+            $table->addColumn('objecttype', 'string', [
652
+                'notnull' => true,
653
+                'length' => 64,
654
+                'default' => '',
655
+            ]);
656
+            $table->addColumn('systemtagid', 'integer', [
657
+                'notnull' => true,
658
+                'length' => 4,
659
+                'default' => 0,
660
+                'unsigned' => true,
661
+            ]);
662
+            $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
663
+        }
664
+
665
+        if (!$schema->hasTable('systemtag_group')) {
666
+            $table = $schema->createTable('systemtag_group');
667
+            $table->addColumn('systemtagid', 'integer', [
668
+                'notnull' => true,
669
+                'length' => 4,
670
+                'default' => 0,
671
+                'unsigned' => true,
672
+            ]);
673
+            $table->addColumn('gid', 'string', [
674
+                'notnull' => true,
675
+            ]);
676
+            $table->setPrimaryKey(['gid', 'systemtagid']);
677
+        }
678
+
679
+        if (!$schema->hasTable('file_locks')) {
680
+            $table = $schema->createTable('file_locks');
681
+            $table->addColumn('id', 'integer', [
682
+                'autoincrement' => true,
683
+                'notnull' => true,
684
+                'length' => 4,
685
+                'unsigned' => true,
686
+            ]);
687
+            $table->addColumn('lock', 'integer', [
688
+                'notnull' => true,
689
+                'length' => 4,
690
+                'default' => 0,
691
+            ]);
692
+            $table->addColumn('key', 'string', [
693
+                'notnull' => true,
694
+                'length' => 64,
695
+            ]);
696
+            $table->addColumn('ttl', 'integer', [
697
+                'notnull' => true,
698
+                'length' => 4,
699
+                'default' => -1,
700
+            ]);
701
+            $table->setPrimaryKey(['id']);
702
+            $table->addUniqueIndex(['key'], 'lock_key_index');
703
+            $table->addIndex(['ttl'], 'lock_ttl_index');
704
+        }
705
+
706
+        if (!$schema->hasTable('comments')) {
707
+            $table = $schema->createTable('comments');
708
+            $table->addColumn('id', 'integer', [
709
+                'autoincrement' => true,
710
+                'notnull' => true,
711
+                'length' => 4,
712
+                'unsigned' => true,
713
+            ]);
714
+            $table->addColumn('parent_id', 'integer', [
715
+                'notnull' => true,
716
+                'length' => 4,
717
+                'default' => 0,
718
+                'unsigned' => true,
719
+            ]);
720
+            $table->addColumn('topmost_parent_id', 'integer', [
721
+                'notnull' => true,
722
+                'length' => 4,
723
+                'default' => 0,
724
+                'unsigned' => true,
725
+            ]);
726
+            $table->addColumn('children_count', 'integer', [
727
+                'notnull' => true,
728
+                'length' => 4,
729
+                'default' => 0,
730
+                'unsigned' => true,
731
+            ]);
732
+            $table->addColumn('actor_type', 'string', [
733
+                'notnull' => true,
734
+                'length' => 64,
735
+                'default' => '',
736
+            ]);
737
+            $table->addColumn('actor_id', 'string', [
738
+                'notnull' => true,
739
+                'length' => 64,
740
+                'default' => '',
741
+            ]);
742
+            $table->addColumn('message', 'text', [
743
+                'notnull' => false,
744
+            ]);
745
+            $table->addColumn('verb', 'string', [
746
+                'notnull' => false,
747
+                'length' => 64,
748
+            ]);
749
+            $table->addColumn('creation_timestamp', 'datetime', [
750
+                'notnull' => false,
751
+            ]);
752
+            $table->addColumn('latest_child_timestamp', 'datetime', [
753
+                'notnull' => false,
754
+            ]);
755
+            $table->addColumn('object_type', 'string', [
756
+                'notnull' => true,
757
+                'length' => 64,
758
+                'default' => '',
759
+            ]);
760
+            $table->addColumn('object_id', 'string', [
761
+                'notnull' => true,
762
+                'length' => 64,
763
+                'default' => '',
764
+            ]);
765
+            $table->setPrimaryKey(['id']);
766
+            $table->addIndex(['parent_id'], 'comments_parent_id_index');
767
+            $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
768
+            $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
769
+            $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
770
+        }
771
+
772
+        if (!$schema->hasTable('comments_read_markers')) {
773
+            $table = $schema->createTable('comments_read_markers');
774
+            $table->addColumn('user_id', 'string', [
775
+                'notnull' => true,
776
+                'length' => 64,
777
+                'default' => '',
778
+            ]);
779
+            $table->addColumn('marker_datetime', 'datetime', [
780
+                'notnull' => false,
781
+            ]);
782
+            $table->addColumn('object_type', 'string', [
783
+                'notnull' => true,
784
+                'length' => 64,
785
+                'default' => '',
786
+            ]);
787
+            $table->addColumn('object_id', 'string', [
788
+                'notnull' => true,
789
+                'length' => 64,
790
+                'default' => '',
791
+            ]);
792
+            $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
793
+            $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
794
+        }
795
+
796
+        if (!$schema->hasTable('credentials')) {
797
+            $table = $schema->createTable('credentials');
798
+            $table->addColumn('user', 'string', [
799
+                'notnull' => true,
800
+                'length' => 64,
801
+            ]);
802
+            $table->addColumn('identifier', 'string', [
803
+                'notnull' => true,
804
+                'length' => 64,
805
+            ]);
806
+            $table->addColumn('credentials', 'text', [
807
+                'notnull' => false,
808
+            ]);
809
+            $table->setPrimaryKey(['user', 'identifier']);
810
+            $table->addIndex(['user'], 'credentials_user');
811
+        }
812
+
813
+        if (!$schema->hasTable('admin_sections')) {
814
+            $table = $schema->createTable('admin_sections');
815
+            $table->addColumn('id', 'string', [
816
+                'notnull' => true,
817
+                'length' => 64,
818
+            ]);
819
+            $table->addColumn('class', 'string', [
820
+                'notnull' => true,
821
+                'length' => 255,
822
+                'default' => '',
823
+            ]);
824
+            $table->addColumn('priority', 'smallint', [
825
+                'notnull' => true,
826
+                'length' => 1,
827
+                'default' => 0,
828
+            ]);
829
+            $table->setPrimaryKey(['id']);
830
+            $table->addUniqueIndex(['class'], 'admin_sections_class');
831
+        }
832
+
833
+        if (!$schema->hasTable('admin_settings')) {
834
+            $table = $schema->createTable('admin_settings');
835
+            $table->addColumn('id', 'integer', [
836
+                'autoincrement' => true,
837
+                'notnull' => true,
838
+                'length' => 4,
839
+            ]);
840
+            $table->addColumn('class', 'string', [
841
+                'notnull' => true,
842
+                'length' => 255,
843
+                'default' => '',
844
+            ]);
845
+            $table->addColumn('section', 'string', [
846
+                'notnull' => false,
847
+                'length' => 64,
848
+            ]);
849
+            $table->addColumn('priority', 'smallint', [
850
+                'notnull' => true,
851
+                'length' => 1,
852
+                'default' => 0,
853
+            ]);
854
+            $table->setPrimaryKey(['id']);
855
+            $table->addUniqueIndex(['class'], 'admin_settings_class');
856
+            $table->addIndex(['section'], 'admin_settings_section');
857
+        }
858
+
859
+        if (!$schema->hasTable('personal_sections')) {
860
+            $table = $schema->createTable('personal_sections');
861
+            $table->addColumn('id', 'string', [
862
+                'notnull' => true,
863
+                'length' => 64,
864
+            ]);
865
+            $table->addColumn('class', 'string', [
866
+                'notnull' => true,
867
+                'length' => 255,
868
+                'default' => '',
869
+            ]);
870
+            $table->addColumn('priority', 'smallint', [
871
+                'notnull' => true,
872
+                'length' => 1,
873
+                'default' => 0,
874
+            ]);
875
+            $table->setPrimaryKey(['id']);
876
+            $table->addUniqueIndex(['class'], 'personal_sections_class');
877
+        }
878
+
879
+        if (!$schema->hasTable('personal_settings')) {
880
+            $table = $schema->createTable('personal_settings');
881
+            $table->addColumn('id', 'integer', [
882
+                'autoincrement' => true,
883
+                'notnull' => true,
884
+                'length' => 4,
885
+            ]);
886
+            $table->addColumn('class', 'string', [
887
+                'notnull' => true,
888
+                'length' => 255,
889
+                'default' => '',
890
+            ]);
891
+            $table->addColumn('section', 'string', [
892
+                'notnull' => false,
893
+                'length' => 64,
894
+            ]);
895
+            $table->addColumn('priority', 'smallint', [
896
+                'notnull' => true,
897
+                'length' => 1,
898
+                'default' => 0,
899
+            ]);
900
+            $table->setPrimaryKey(['id']);
901
+            $table->addUniqueIndex(['class'], 'personal_settings_class');
902
+            $table->addIndex(['section'], 'personal_settings_section');
903
+        }
904
+
905
+        if (!$schema->hasTable('accounts')) {
906
+            $table = $schema->createTable('accounts');
907
+            $table->addColumn('uid', 'string', [
908
+                'notnull' => true,
909
+                'length' => 64,
910
+                'default' => '',
911
+            ]);
912
+            $table->addColumn('data', 'text', [
913
+                'notnull' => true,
914
+                'default' => '',
915
+            ]);
916
+            $table->setPrimaryKey(['uid']);
917
+        }
918
+        return $schema;
919
+    }
920 920
 
921 921
 }
Please login to merge, or discard this patch.