Passed
Push — master ( ee68e8...01d5cc )
by Morris
15:51 queued 05:18
created
core/Migrations/Version13000Date20170718121200.php 1 patch
Indentation   +890 added lines, -890 removed lines patch added patch discarded remove patch
@@ -30,895 +30,895 @@
 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', Type::BIGINT, [
180
-				'notnull' => true,
181
-				'length' => 20,
182
-				'default' => 0,
183
-			]);
184
-			$table->addColumn('storage_mtime', Type::BIGINT, [
185
-				'notnull' => true,
186
-				'length' => 20,
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
-			$table->addIndex(['mtime'], 'fs_mtime');
219
-		}
220
-
221
-		if (!$schema->hasTable('group_user')) {
222
-			$table = $schema->createTable('group_user');
223
-			$table->addColumn('gid', 'string', [
224
-				'notnull' => true,
225
-				'length' => 64,
226
-				'default' => '',
227
-			]);
228
-			$table->addColumn('uid', 'string', [
229
-				'notnull' => true,
230
-				'length' => 64,
231
-				'default' => '',
232
-			]);
233
-			$table->setPrimaryKey(['gid', 'uid']);
234
-			$table->addIndex(['uid'], 'gu_uid_index');
235
-		}
236
-
237
-		if (!$schema->hasTable('group_admin')) {
238
-			$table = $schema->createTable('group_admin');
239
-			$table->addColumn('gid', 'string', [
240
-				'notnull' => true,
241
-				'length' => 64,
242
-				'default' => '',
243
-			]);
244
-			$table->addColumn('uid', 'string', [
245
-				'notnull' => true,
246
-				'length' => 64,
247
-				'default' => '',
248
-			]);
249
-			$table->setPrimaryKey(['gid', 'uid']);
250
-			$table->addIndex(['uid'], 'group_admin_uid');
251
-		}
252
-
253
-		if (!$schema->hasTable('groups')) {
254
-			$table = $schema->createTable('groups');
255
-			$table->addColumn('gid', 'string', [
256
-				'notnull' => true,
257
-				'length' => 64,
258
-				'default' => '',
259
-			]);
260
-			$table->setPrimaryKey(['gid']);
261
-		}
262
-
263
-		if (!$schema->hasTable('preferences')) {
264
-			$table = $schema->createTable('preferences');
265
-			$table->addColumn('userid', 'string', [
266
-				'notnull' => true,
267
-				'length' => 64,
268
-				'default' => '',
269
-			]);
270
-			$table->addColumn('appid', 'string', [
271
-				'notnull' => true,
272
-				'length' => 32,
273
-				'default' => '',
274
-			]);
275
-			$table->addColumn('configkey', 'string', [
276
-				'notnull' => true,
277
-				'length' => 64,
278
-				'default' => '',
279
-			]);
280
-			$table->addColumn('configvalue', 'text', [
281
-				'notnull' => false,
282
-			]);
283
-			$table->setPrimaryKey(['userid', 'appid', 'configkey']);
284
-		}
285
-
286
-		if (!$schema->hasTable('properties')) {
287
-			$table = $schema->createTable('properties');
288
-			$table->addColumn('id', 'integer', [
289
-				'autoincrement' => true,
290
-				'notnull' => true,
291
-				'length' => 4,
292
-			]);
293
-			$table->addColumn('userid', 'string', [
294
-				'notnull' => true,
295
-				'length' => 64,
296
-				'default' => '',
297
-			]);
298
-			$table->addColumn('propertypath', 'string', [
299
-				'notnull' => true,
300
-				'length' => 255,
301
-				'default' => '',
302
-			]);
303
-			$table->addColumn('propertyname', 'string', [
304
-				'notnull' => true,
305
-				'length' => 255,
306
-				'default' => '',
307
-			]);
308
-			$table->addColumn('propertyvalue', 'text', [
309
-				'notnull' => true,
310
-			]);
311
-			$table->setPrimaryKey(['id']);
312
-			$table->addIndex(['userid'], 'property_index');
313
-		}
314
-
315
-		if (!$schema->hasTable('share')) {
316
-			$table = $schema->createTable('share');
317
-			$table->addColumn('id', 'integer', [
318
-				'autoincrement' => true,
319
-				'notnull' => true,
320
-				'length' => 4,
321
-			]);
322
-			$table->addColumn('share_type', 'smallint', [
323
-				'notnull' => true,
324
-				'length' => 1,
325
-				'default' => 0,
326
-			]);
327
-			$table->addColumn('share_with', 'string', [
328
-				'notnull' => false,
329
-				'length' => 255,
330
-			]);
331
-			$table->addColumn('password', 'string', [
332
-				'notnull' => false,
333
-				'length' => 255,
334
-			]);
335
-			$table->addColumn('uid_owner', 'string', [
336
-				'notnull' => true,
337
-				'length' => 64,
338
-				'default' => '',
339
-			]);
340
-			$table->addColumn('uid_initiator', 'string', [
341
-				'notnull' => false,
342
-				'length' => 64,
343
-			]);
344
-			$table->addColumn('parent', 'integer', [
345
-				'notnull' => false,
346
-				'length' => 4,
347
-			]);
348
-			$table->addColumn('item_type', 'string', [
349
-				'notnull' => true,
350
-				'length' => 64,
351
-				'default' => '',
352
-			]);
353
-			$table->addColumn('item_source', 'string', [
354
-				'notnull' => false,
355
-				'length' => 255,
356
-			]);
357
-			$table->addColumn('item_target', 'string', [
358
-				'notnull' => false,
359
-				'length' => 255,
360
-			]);
361
-			$table->addColumn('file_source', 'integer', [
362
-				'notnull' => false,
363
-				'length' => 4,
364
-			]);
365
-			$table->addColumn('file_target', 'string', [
366
-				'notnull' => false,
367
-				'length' => 512,
368
-			]);
369
-			$table->addColumn('permissions', 'smallint', [
370
-				'notnull' => true,
371
-				'length' => 1,
372
-				'default' => 0,
373
-			]);
374
-			$table->addColumn('stime', 'bigint', [
375
-				'notnull' => true,
376
-				'length' => 8,
377
-				'default' => 0,
378
-			]);
379
-			$table->addColumn('accepted', 'smallint', [
380
-				'notnull' => true,
381
-				'length' => 1,
382
-				'default' => 0,
383
-			]);
384
-			$table->addColumn('expiration', 'datetime', [
385
-				'notnull' => false,
386
-			]);
387
-			$table->addColumn('token', 'string', [
388
-				'notnull' => false,
389
-				'length' => 32,
390
-			]);
391
-			$table->addColumn('mail_send', 'smallint', [
392
-				'notnull' => true,
393
-				'length' => 1,
394
-				'default' => 0,
395
-			]);
396
-			$table->addColumn('share_name', 'string', [
397
-				'notnull' => false,
398
-				'length' => 64,
399
-			]);
400
-			$table->setPrimaryKey(['id']);
401
-			$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
402
-			$table->addIndex(['file_source'], 'file_source_index');
403
-			$table->addIndex(['token'], 'token_index');
404
-			$table->addIndex(['share_with'], 'share_with_index');
405
-			$table->addIndex(['parent'], 'parent_index');
406
-			$table->addIndex(['uid_owner'], 'owner_index');
407
-			$table->addIndex(['uid_initiator'], 'initiator_index');
408
-		}
409
-
410
-		if (!$schema->hasTable('jobs')) {
411
-			$table = $schema->createTable('jobs');
412
-			$table->addColumn('id', 'integer', [
413
-				'autoincrement' => true,
414
-				'notnull' => true,
415
-				'length' => 4,
416
-				'unsigned' => true,
417
-			]);
418
-			$table->addColumn('class', 'string', [
419
-				'notnull' => true,
420
-				'length' => 255,
421
-				'default' => '',
422
-			]);
423
-			$table->addColumn('argument', 'string', [
424
-				'notnull' => true,
425
-				'length' => 4000,
426
-				'default' => '',
427
-			]);
428
-			$table->addColumn('last_run', 'integer', [
429
-				'notnull' => false,
430
-				'default' => 0,
431
-			]);
432
-			$table->addColumn('last_checked', 'integer', [
433
-				'notnull' => false,
434
-				'default' => 0,
435
-			]);
436
-			$table->addColumn('reserved_at', 'integer', [
437
-				'notnull' => false,
438
-				'default' => 0,
439
-			]);
440
-			$table->addColumn('execution_duration', 'integer', [
441
-				'notnull' => true,
442
-				'default' => 0,
443
-			]);
444
-			$table->setPrimaryKey(['id']);
445
-			$table->addIndex(['class'], 'job_class_index');
446
-		}
447
-
448
-		if (!$schema->hasTable('users')) {
449
-			$table = $schema->createTable('users');
450
-			$table->addColumn('uid', 'string', [
451
-				'notnull' => true,
452
-				'length' => 64,
453
-				'default' => '',
454
-			]);
455
-			$table->addColumn('displayname', 'string', [
456
-				'notnull' => false,
457
-				'length' => 64,
458
-			]);
459
-			$table->addColumn('password', 'string', [
460
-				'notnull' => true,
461
-				'length' => 255,
462
-				'default' => '',
463
-			]);
464
-			$table->setPrimaryKey(['uid']);
465
-		}
466
-
467
-		if (!$schema->hasTable('authtoken')) {
468
-			$table = $schema->createTable('authtoken');
469
-			$table->addColumn('id', 'integer', [
470
-				'autoincrement' => true,
471
-				'notnull' => true,
472
-				'length' => 4,
473
-				'unsigned' => true,
474
-			]);
475
-			$table->addColumn('uid', 'string', [
476
-				'notnull' => true,
477
-				'length' => 64,
478
-				'default' => '',
479
-			]);
480
-			$table->addColumn('login_name', 'string', [
481
-				'notnull' => true,
482
-				'length' => 64,
483
-				'default' => '',
484
-			]);
485
-			$table->addColumn('password', 'text', [
486
-				'notnull' => false,
487
-			]);
488
-			$table->addColumn('name', 'text', [
489
-				'notnull' => true,
490
-				'default' => '',
491
-			]);
492
-			$table->addColumn('token', 'string', [
493
-				'notnull' => true,
494
-				'length' => 200,
495
-				'default' => '',
496
-			]);
497
-			$table->addColumn('type', 'smallint', [
498
-				'notnull' => true,
499
-				'length' => 2,
500
-				'default' => 0,
501
-				'unsigned' => true,
502
-			]);
503
-			$table->addColumn('remember', 'smallint', [
504
-				'notnull' => true,
505
-				'length' => 1,
506
-				'default' => 0,
507
-				'unsigned' => true,
508
-			]);
509
-			$table->addColumn('last_activity', 'integer', [
510
-				'notnull' => true,
511
-				'length' => 4,
512
-				'default' => 0,
513
-				'unsigned' => true,
514
-			]);
515
-			$table->addColumn('last_check', 'integer', [
516
-				'notnull' => true,
517
-				'length' => 4,
518
-				'default' => 0,
519
-				'unsigned' => true,
520
-			]);
521
-			$table->addColumn('scope', 'text', [
522
-				'notnull' => false,
523
-			]);
524
-			$table->setPrimaryKey(['id']);
525
-			$table->addUniqueIndex(['token'], 'authtoken_token_index');
526
-			$table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
527
-		}
528
-
529
-		if (!$schema->hasTable('bruteforce_attempts')) {
530
-			$table = $schema->createTable('bruteforce_attempts');
531
-			$table->addColumn('id', 'integer', [
532
-				'autoincrement' => true,
533
-				'notnull' => true,
534
-				'length' => 4,
535
-				'unsigned' => true,
536
-			]);
537
-			$table->addColumn('action', 'string', [
538
-				'notnull' => true,
539
-				'length' => 64,
540
-				'default' => '',
541
-			]);
542
-			$table->addColumn('occurred', 'integer', [
543
-				'notnull' => true,
544
-				'length' => 4,
545
-				'default' => 0,
546
-				'unsigned' => true,
547
-			]);
548
-			$table->addColumn('ip', 'string', [
549
-				'notnull' => true,
550
-				'length' => 255,
551
-				'default' => '',
552
-			]);
553
-			$table->addColumn('subnet', 'string', [
554
-				'notnull' => true,
555
-				'length' => 255,
556
-				'default' => '',
557
-			]);
558
-			$table->addColumn('metadata', 'string', [
559
-				'notnull' => true,
560
-				'length' => 255,
561
-				'default' => '',
562
-			]);
563
-			$table->setPrimaryKey(['id']);
564
-			$table->addIndex(['ip'], 'bruteforce_attempts_ip');
565
-			$table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
566
-		}
567
-
568
-		if (!$schema->hasTable('vcategory')) {
569
-			$table = $schema->createTable('vcategory');
570
-			$table->addColumn('id', 'integer', [
571
-				'autoincrement' => true,
572
-				'notnull' => true,
573
-				'length' => 4,
574
-				'unsigned' => true,
575
-			]);
576
-			$table->addColumn('uid', 'string', [
577
-				'notnull' => true,
578
-				'length' => 64,
579
-				'default' => '',
580
-			]);
581
-			$table->addColumn('type', 'string', [
582
-				'notnull' => true,
583
-				'length' => 64,
584
-				'default' => '',
585
-			]);
586
-			$table->addColumn('category', 'string', [
587
-				'notnull' => true,
588
-				'length' => 255,
589
-				'default' => '',
590
-			]);
591
-			$table->setPrimaryKey(['id']);
592
-			$table->addIndex(['uid'], 'uid_index');
593
-			$table->addIndex(['type'], 'type_index');
594
-			$table->addIndex(['category'], 'category_index');
595
-		}
596
-
597
-		if (!$schema->hasTable('vcategory_to_object')) {
598
-			$table = $schema->createTable('vcategory_to_object');
599
-			$table->addColumn('objid', 'integer', [
600
-				'notnull' => true,
601
-				'length' => 4,
602
-				'default' => 0,
603
-				'unsigned' => true,
604
-			]);
605
-			$table->addColumn('categoryid', 'integer', [
606
-				'notnull' => true,
607
-				'length' => 4,
608
-				'default' => 0,
609
-				'unsigned' => true,
610
-			]);
611
-			$table->addColumn('type', 'string', [
612
-				'notnull' => true,
613
-				'length' => 64,
614
-				'default' => '',
615
-			]);
616
-			$table->setPrimaryKey(['categoryid', 'objid', 'type']);
617
-			$table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
618
-		}
619
-
620
-		if (!$schema->hasTable('systemtag')) {
621
-			$table = $schema->createTable('systemtag');
622
-			$table->addColumn('id', 'integer', [
623
-				'autoincrement' => true,
624
-				'notnull' => true,
625
-				'length' => 4,
626
-				'unsigned' => true,
627
-			]);
628
-			$table->addColumn('name', 'string', [
629
-				'notnull' => true,
630
-				'length' => 64,
631
-				'default' => '',
632
-			]);
633
-			$table->addColumn('visibility', 'smallint', [
634
-				'notnull' => true,
635
-				'length' => 1,
636
-				'default' => 1,
637
-			]);
638
-			$table->addColumn('editable', 'smallint', [
639
-				'notnull' => true,
640
-				'length' => 1,
641
-				'default' => 1,
642
-			]);
643
-			$table->setPrimaryKey(['id']);
644
-			$table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
645
-		}
646
-
647
-		if (!$schema->hasTable('systemtag_object_mapping')) {
648
-			$table = $schema->createTable('systemtag_object_mapping');
649
-			$table->addColumn('objectid', 'string', [
650
-				'notnull' => true,
651
-				'length' => 64,
652
-				'default' => '',
653
-			]);
654
-			$table->addColumn('objecttype', 'string', [
655
-				'notnull' => true,
656
-				'length' => 64,
657
-				'default' => '',
658
-			]);
659
-			$table->addColumn('systemtagid', 'integer', [
660
-				'notnull' => true,
661
-				'length' => 4,
662
-				'default' => 0,
663
-				'unsigned' => true,
664
-			]);
665
-			$table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
666
-		}
667
-
668
-		if (!$schema->hasTable('systemtag_group')) {
669
-			$table = $schema->createTable('systemtag_group');
670
-			$table->addColumn('systemtagid', 'integer', [
671
-				'notnull' => true,
672
-				'length' => 4,
673
-				'default' => 0,
674
-				'unsigned' => true,
675
-			]);
676
-			$table->addColumn('gid', 'string', [
677
-				'notnull' => true,
678
-			]);
679
-			$table->setPrimaryKey(['gid', 'systemtagid']);
680
-		}
681
-
682
-		if (!$schema->hasTable('file_locks')) {
683
-			$table = $schema->createTable('file_locks');
684
-			$table->addColumn('id', 'integer', [
685
-				'autoincrement' => true,
686
-				'notnull' => true,
687
-				'length' => 4,
688
-				'unsigned' => true,
689
-			]);
690
-			$table->addColumn('lock', 'integer', [
691
-				'notnull' => true,
692
-				'length' => 4,
693
-				'default' => 0,
694
-			]);
695
-			$table->addColumn('key', 'string', [
696
-				'notnull' => true,
697
-				'length' => 64,
698
-			]);
699
-			$table->addColumn('ttl', 'integer', [
700
-				'notnull' => true,
701
-				'length' => 4,
702
-				'default' => -1,
703
-			]);
704
-			$table->setPrimaryKey(['id']);
705
-			$table->addUniqueIndex(['key'], 'lock_key_index');
706
-			$table->addIndex(['ttl'], 'lock_ttl_index');
707
-		}
708
-
709
-		if (!$schema->hasTable('comments')) {
710
-			$table = $schema->createTable('comments');
711
-			$table->addColumn('id', 'integer', [
712
-				'autoincrement' => true,
713
-				'notnull' => true,
714
-				'length' => 4,
715
-				'unsigned' => true,
716
-			]);
717
-			$table->addColumn('parent_id', 'integer', [
718
-				'notnull' => true,
719
-				'length' => 4,
720
-				'default' => 0,
721
-				'unsigned' => true,
722
-			]);
723
-			$table->addColumn('topmost_parent_id', 'integer', [
724
-				'notnull' => true,
725
-				'length' => 4,
726
-				'default' => 0,
727
-				'unsigned' => true,
728
-			]);
729
-			$table->addColumn('children_count', 'integer', [
730
-				'notnull' => true,
731
-				'length' => 4,
732
-				'default' => 0,
733
-				'unsigned' => true,
734
-			]);
735
-			$table->addColumn('actor_type', 'string', [
736
-				'notnull' => true,
737
-				'length' => 64,
738
-				'default' => '',
739
-			]);
740
-			$table->addColumn('actor_id', 'string', [
741
-				'notnull' => true,
742
-				'length' => 64,
743
-				'default' => '',
744
-			]);
745
-			$table->addColumn('message', 'text', [
746
-				'notnull' => false,
747
-			]);
748
-			$table->addColumn('verb', 'string', [
749
-				'notnull' => false,
750
-				'length' => 64,
751
-			]);
752
-			$table->addColumn('creation_timestamp', 'datetime', [
753
-				'notnull' => false,
754
-			]);
755
-			$table->addColumn('latest_child_timestamp', 'datetime', [
756
-				'notnull' => false,
757
-			]);
758
-			$table->addColumn('object_type', 'string', [
759
-				'notnull' => true,
760
-				'length' => 64,
761
-				'default' => '',
762
-			]);
763
-			$table->addColumn('object_id', 'string', [
764
-				'notnull' => true,
765
-				'length' => 64,
766
-				'default' => '',
767
-			]);
768
-			$table->setPrimaryKey(['id']);
769
-			$table->addIndex(['parent_id'], 'comments_parent_id_index');
770
-			$table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
771
-			$table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
772
-			$table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
773
-		}
774
-
775
-		if (!$schema->hasTable('comments_read_markers')) {
776
-			$table = $schema->createTable('comments_read_markers');
777
-			$table->addColumn('user_id', 'string', [
778
-				'notnull' => true,
779
-				'length' => 64,
780
-				'default' => '',
781
-			]);
782
-			$table->addColumn('marker_datetime', 'datetime', [
783
-				'notnull' => false,
784
-			]);
785
-			$table->addColumn('object_type', 'string', [
786
-				'notnull' => true,
787
-				'length' => 64,
788
-				'default' => '',
789
-			]);
790
-			$table->addColumn('object_id', 'string', [
791
-				'notnull' => true,
792
-				'length' => 64,
793
-				'default' => '',
794
-			]);
795
-			$table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
796
-			$table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
797
-		}
798
-
799
-		if (!$schema->hasTable('credentials')) {
800
-			$table = $schema->createTable('credentials');
801
-			$table->addColumn('user', 'string', [
802
-				'notnull' => true,
803
-				'length' => 64,
804
-			]);
805
-			$table->addColumn('identifier', 'string', [
806
-				'notnull' => true,
807
-				'length' => 64,
808
-			]);
809
-			$table->addColumn('credentials', 'text', [
810
-				'notnull' => false,
811
-			]);
812
-			$table->setPrimaryKey(['user', 'identifier']);
813
-			$table->addIndex(['user'], 'credentials_user');
814
-		}
815
-
816
-		if (!$schema->hasTable('admin_sections')) {
817
-			$table = $schema->createTable('admin_sections');
818
-			$table->addColumn('id', 'string', [
819
-				'notnull' => true,
820
-				'length' => 64,
821
-			]);
822
-			$table->addColumn('class', 'string', [
823
-				'notnull' => true,
824
-				'length' => 255,
825
-				'default' => '',
826
-			]);
827
-			$table->addColumn('priority', 'smallint', [
828
-				'notnull' => true,
829
-				'length' => 1,
830
-				'default' => 0,
831
-			]);
832
-			$table->setPrimaryKey(['id']);
833
-			$table->addUniqueIndex(['class'], 'admin_sections_class');
834
-		}
835
-
836
-		if (!$schema->hasTable('admin_settings')) {
837
-			$table = $schema->createTable('admin_settings');
838
-			$table->addColumn('id', 'integer', [
839
-				'autoincrement' => true,
840
-				'notnull' => true,
841
-				'length' => 4,
842
-			]);
843
-			$table->addColumn('class', 'string', [
844
-				'notnull' => true,
845
-				'length' => 255,
846
-				'default' => '',
847
-			]);
848
-			$table->addColumn('section', 'string', [
849
-				'notnull' => false,
850
-				'length' => 64,
851
-			]);
852
-			$table->addColumn('priority', 'smallint', [
853
-				'notnull' => true,
854
-				'length' => 1,
855
-				'default' => 0,
856
-			]);
857
-			$table->setPrimaryKey(['id']);
858
-			$table->addUniqueIndex(['class'], 'admin_settings_class');
859
-			$table->addIndex(['section'], 'admin_settings_section');
860
-		}
861
-
862
-		if (!$schema->hasTable('personal_sections')) {
863
-			$table = $schema->createTable('personal_sections');
864
-			$table->addColumn('id', 'string', [
865
-				'notnull' => true,
866
-				'length' => 64,
867
-			]);
868
-			$table->addColumn('class', 'string', [
869
-				'notnull' => true,
870
-				'length' => 255,
871
-				'default' => '',
872
-			]);
873
-			$table->addColumn('priority', 'smallint', [
874
-				'notnull' => true,
875
-				'length' => 1,
876
-				'default' => 0,
877
-			]);
878
-			$table->setPrimaryKey(['id']);
879
-			$table->addUniqueIndex(['class'], 'personal_sections_class');
880
-		}
881
-
882
-		if (!$schema->hasTable('personal_settings')) {
883
-			$table = $schema->createTable('personal_settings');
884
-			$table->addColumn('id', 'integer', [
885
-				'autoincrement' => true,
886
-				'notnull' => true,
887
-				'length' => 4,
888
-			]);
889
-			$table->addColumn('class', 'string', [
890
-				'notnull' => true,
891
-				'length' => 255,
892
-				'default' => '',
893
-			]);
894
-			$table->addColumn('section', 'string', [
895
-				'notnull' => false,
896
-				'length' => 64,
897
-			]);
898
-			$table->addColumn('priority', 'smallint', [
899
-				'notnull' => true,
900
-				'length' => 1,
901
-				'default' => 0,
902
-			]);
903
-			$table->setPrimaryKey(['id']);
904
-			$table->addUniqueIndex(['class'], 'personal_settings_class');
905
-			$table->addIndex(['section'], 'personal_settings_section');
906
-		}
907
-
908
-		if (!$schema->hasTable('accounts')) {
909
-			$table = $schema->createTable('accounts');
910
-			$table->addColumn('uid', 'string', [
911
-				'notnull' => true,
912
-				'length' => 64,
913
-				'default' => '',
914
-			]);
915
-			$table->addColumn('data', 'text', [
916
-				'notnull' => true,
917
-				'default' => '',
918
-			]);
919
-			$table->setPrimaryKey(['uid']);
920
-		}
921
-		return $schema;
922
-	}
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', Type::BIGINT, [
180
+                'notnull' => true,
181
+                'length' => 20,
182
+                'default' => 0,
183
+            ]);
184
+            $table->addColumn('storage_mtime', Type::BIGINT, [
185
+                'notnull' => true,
186
+                'length' => 20,
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
+            $table->addIndex(['mtime'], 'fs_mtime');
219
+        }
220
+
221
+        if (!$schema->hasTable('group_user')) {
222
+            $table = $schema->createTable('group_user');
223
+            $table->addColumn('gid', 'string', [
224
+                'notnull' => true,
225
+                'length' => 64,
226
+                'default' => '',
227
+            ]);
228
+            $table->addColumn('uid', 'string', [
229
+                'notnull' => true,
230
+                'length' => 64,
231
+                'default' => '',
232
+            ]);
233
+            $table->setPrimaryKey(['gid', 'uid']);
234
+            $table->addIndex(['uid'], 'gu_uid_index');
235
+        }
236
+
237
+        if (!$schema->hasTable('group_admin')) {
238
+            $table = $schema->createTable('group_admin');
239
+            $table->addColumn('gid', 'string', [
240
+                'notnull' => true,
241
+                'length' => 64,
242
+                'default' => '',
243
+            ]);
244
+            $table->addColumn('uid', 'string', [
245
+                'notnull' => true,
246
+                'length' => 64,
247
+                'default' => '',
248
+            ]);
249
+            $table->setPrimaryKey(['gid', 'uid']);
250
+            $table->addIndex(['uid'], 'group_admin_uid');
251
+        }
252
+
253
+        if (!$schema->hasTable('groups')) {
254
+            $table = $schema->createTable('groups');
255
+            $table->addColumn('gid', 'string', [
256
+                'notnull' => true,
257
+                'length' => 64,
258
+                'default' => '',
259
+            ]);
260
+            $table->setPrimaryKey(['gid']);
261
+        }
262
+
263
+        if (!$schema->hasTable('preferences')) {
264
+            $table = $schema->createTable('preferences');
265
+            $table->addColumn('userid', 'string', [
266
+                'notnull' => true,
267
+                'length' => 64,
268
+                'default' => '',
269
+            ]);
270
+            $table->addColumn('appid', 'string', [
271
+                'notnull' => true,
272
+                'length' => 32,
273
+                'default' => '',
274
+            ]);
275
+            $table->addColumn('configkey', 'string', [
276
+                'notnull' => true,
277
+                'length' => 64,
278
+                'default' => '',
279
+            ]);
280
+            $table->addColumn('configvalue', 'text', [
281
+                'notnull' => false,
282
+            ]);
283
+            $table->setPrimaryKey(['userid', 'appid', 'configkey']);
284
+        }
285
+
286
+        if (!$schema->hasTable('properties')) {
287
+            $table = $schema->createTable('properties');
288
+            $table->addColumn('id', 'integer', [
289
+                'autoincrement' => true,
290
+                'notnull' => true,
291
+                'length' => 4,
292
+            ]);
293
+            $table->addColumn('userid', 'string', [
294
+                'notnull' => true,
295
+                'length' => 64,
296
+                'default' => '',
297
+            ]);
298
+            $table->addColumn('propertypath', 'string', [
299
+                'notnull' => true,
300
+                'length' => 255,
301
+                'default' => '',
302
+            ]);
303
+            $table->addColumn('propertyname', 'string', [
304
+                'notnull' => true,
305
+                'length' => 255,
306
+                'default' => '',
307
+            ]);
308
+            $table->addColumn('propertyvalue', 'text', [
309
+                'notnull' => true,
310
+            ]);
311
+            $table->setPrimaryKey(['id']);
312
+            $table->addIndex(['userid'], 'property_index');
313
+        }
314
+
315
+        if (!$schema->hasTable('share')) {
316
+            $table = $schema->createTable('share');
317
+            $table->addColumn('id', 'integer', [
318
+                'autoincrement' => true,
319
+                'notnull' => true,
320
+                'length' => 4,
321
+            ]);
322
+            $table->addColumn('share_type', 'smallint', [
323
+                'notnull' => true,
324
+                'length' => 1,
325
+                'default' => 0,
326
+            ]);
327
+            $table->addColumn('share_with', 'string', [
328
+                'notnull' => false,
329
+                'length' => 255,
330
+            ]);
331
+            $table->addColumn('password', 'string', [
332
+                'notnull' => false,
333
+                'length' => 255,
334
+            ]);
335
+            $table->addColumn('uid_owner', 'string', [
336
+                'notnull' => true,
337
+                'length' => 64,
338
+                'default' => '',
339
+            ]);
340
+            $table->addColumn('uid_initiator', 'string', [
341
+                'notnull' => false,
342
+                'length' => 64,
343
+            ]);
344
+            $table->addColumn('parent', 'integer', [
345
+                'notnull' => false,
346
+                'length' => 4,
347
+            ]);
348
+            $table->addColumn('item_type', 'string', [
349
+                'notnull' => true,
350
+                'length' => 64,
351
+                'default' => '',
352
+            ]);
353
+            $table->addColumn('item_source', 'string', [
354
+                'notnull' => false,
355
+                'length' => 255,
356
+            ]);
357
+            $table->addColumn('item_target', 'string', [
358
+                'notnull' => false,
359
+                'length' => 255,
360
+            ]);
361
+            $table->addColumn('file_source', 'integer', [
362
+                'notnull' => false,
363
+                'length' => 4,
364
+            ]);
365
+            $table->addColumn('file_target', 'string', [
366
+                'notnull' => false,
367
+                'length' => 512,
368
+            ]);
369
+            $table->addColumn('permissions', 'smallint', [
370
+                'notnull' => true,
371
+                'length' => 1,
372
+                'default' => 0,
373
+            ]);
374
+            $table->addColumn('stime', 'bigint', [
375
+                'notnull' => true,
376
+                'length' => 8,
377
+                'default' => 0,
378
+            ]);
379
+            $table->addColumn('accepted', 'smallint', [
380
+                'notnull' => true,
381
+                'length' => 1,
382
+                'default' => 0,
383
+            ]);
384
+            $table->addColumn('expiration', 'datetime', [
385
+                'notnull' => false,
386
+            ]);
387
+            $table->addColumn('token', 'string', [
388
+                'notnull' => false,
389
+                'length' => 32,
390
+            ]);
391
+            $table->addColumn('mail_send', 'smallint', [
392
+                'notnull' => true,
393
+                'length' => 1,
394
+                'default' => 0,
395
+            ]);
396
+            $table->addColumn('share_name', 'string', [
397
+                'notnull' => false,
398
+                'length' => 64,
399
+            ]);
400
+            $table->setPrimaryKey(['id']);
401
+            $table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
402
+            $table->addIndex(['file_source'], 'file_source_index');
403
+            $table->addIndex(['token'], 'token_index');
404
+            $table->addIndex(['share_with'], 'share_with_index');
405
+            $table->addIndex(['parent'], 'parent_index');
406
+            $table->addIndex(['uid_owner'], 'owner_index');
407
+            $table->addIndex(['uid_initiator'], 'initiator_index');
408
+        }
409
+
410
+        if (!$schema->hasTable('jobs')) {
411
+            $table = $schema->createTable('jobs');
412
+            $table->addColumn('id', 'integer', [
413
+                'autoincrement' => true,
414
+                'notnull' => true,
415
+                'length' => 4,
416
+                'unsigned' => true,
417
+            ]);
418
+            $table->addColumn('class', 'string', [
419
+                'notnull' => true,
420
+                'length' => 255,
421
+                'default' => '',
422
+            ]);
423
+            $table->addColumn('argument', 'string', [
424
+                'notnull' => true,
425
+                'length' => 4000,
426
+                'default' => '',
427
+            ]);
428
+            $table->addColumn('last_run', 'integer', [
429
+                'notnull' => false,
430
+                'default' => 0,
431
+            ]);
432
+            $table->addColumn('last_checked', 'integer', [
433
+                'notnull' => false,
434
+                'default' => 0,
435
+            ]);
436
+            $table->addColumn('reserved_at', 'integer', [
437
+                'notnull' => false,
438
+                'default' => 0,
439
+            ]);
440
+            $table->addColumn('execution_duration', 'integer', [
441
+                'notnull' => true,
442
+                'default' => 0,
443
+            ]);
444
+            $table->setPrimaryKey(['id']);
445
+            $table->addIndex(['class'], 'job_class_index');
446
+        }
447
+
448
+        if (!$schema->hasTable('users')) {
449
+            $table = $schema->createTable('users');
450
+            $table->addColumn('uid', 'string', [
451
+                'notnull' => true,
452
+                'length' => 64,
453
+                'default' => '',
454
+            ]);
455
+            $table->addColumn('displayname', 'string', [
456
+                'notnull' => false,
457
+                'length' => 64,
458
+            ]);
459
+            $table->addColumn('password', 'string', [
460
+                'notnull' => true,
461
+                'length' => 255,
462
+                'default' => '',
463
+            ]);
464
+            $table->setPrimaryKey(['uid']);
465
+        }
466
+
467
+        if (!$schema->hasTable('authtoken')) {
468
+            $table = $schema->createTable('authtoken');
469
+            $table->addColumn('id', 'integer', [
470
+                'autoincrement' => true,
471
+                'notnull' => true,
472
+                'length' => 4,
473
+                'unsigned' => true,
474
+            ]);
475
+            $table->addColumn('uid', 'string', [
476
+                'notnull' => true,
477
+                'length' => 64,
478
+                'default' => '',
479
+            ]);
480
+            $table->addColumn('login_name', 'string', [
481
+                'notnull' => true,
482
+                'length' => 64,
483
+                'default' => '',
484
+            ]);
485
+            $table->addColumn('password', 'text', [
486
+                'notnull' => false,
487
+            ]);
488
+            $table->addColumn('name', 'text', [
489
+                'notnull' => true,
490
+                'default' => '',
491
+            ]);
492
+            $table->addColumn('token', 'string', [
493
+                'notnull' => true,
494
+                'length' => 200,
495
+                'default' => '',
496
+            ]);
497
+            $table->addColumn('type', 'smallint', [
498
+                'notnull' => true,
499
+                'length' => 2,
500
+                'default' => 0,
501
+                'unsigned' => true,
502
+            ]);
503
+            $table->addColumn('remember', 'smallint', [
504
+                'notnull' => true,
505
+                'length' => 1,
506
+                'default' => 0,
507
+                'unsigned' => true,
508
+            ]);
509
+            $table->addColumn('last_activity', 'integer', [
510
+                'notnull' => true,
511
+                'length' => 4,
512
+                'default' => 0,
513
+                'unsigned' => true,
514
+            ]);
515
+            $table->addColumn('last_check', 'integer', [
516
+                'notnull' => true,
517
+                'length' => 4,
518
+                'default' => 0,
519
+                'unsigned' => true,
520
+            ]);
521
+            $table->addColumn('scope', 'text', [
522
+                'notnull' => false,
523
+            ]);
524
+            $table->setPrimaryKey(['id']);
525
+            $table->addUniqueIndex(['token'], 'authtoken_token_index');
526
+            $table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
527
+        }
528
+
529
+        if (!$schema->hasTable('bruteforce_attempts')) {
530
+            $table = $schema->createTable('bruteforce_attempts');
531
+            $table->addColumn('id', 'integer', [
532
+                'autoincrement' => true,
533
+                'notnull' => true,
534
+                'length' => 4,
535
+                'unsigned' => true,
536
+            ]);
537
+            $table->addColumn('action', 'string', [
538
+                'notnull' => true,
539
+                'length' => 64,
540
+                'default' => '',
541
+            ]);
542
+            $table->addColumn('occurred', 'integer', [
543
+                'notnull' => true,
544
+                'length' => 4,
545
+                'default' => 0,
546
+                'unsigned' => true,
547
+            ]);
548
+            $table->addColumn('ip', 'string', [
549
+                'notnull' => true,
550
+                'length' => 255,
551
+                'default' => '',
552
+            ]);
553
+            $table->addColumn('subnet', 'string', [
554
+                'notnull' => true,
555
+                'length' => 255,
556
+                'default' => '',
557
+            ]);
558
+            $table->addColumn('metadata', 'string', [
559
+                'notnull' => true,
560
+                'length' => 255,
561
+                'default' => '',
562
+            ]);
563
+            $table->setPrimaryKey(['id']);
564
+            $table->addIndex(['ip'], 'bruteforce_attempts_ip');
565
+            $table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
566
+        }
567
+
568
+        if (!$schema->hasTable('vcategory')) {
569
+            $table = $schema->createTable('vcategory');
570
+            $table->addColumn('id', 'integer', [
571
+                'autoincrement' => true,
572
+                'notnull' => true,
573
+                'length' => 4,
574
+                'unsigned' => true,
575
+            ]);
576
+            $table->addColumn('uid', 'string', [
577
+                'notnull' => true,
578
+                'length' => 64,
579
+                'default' => '',
580
+            ]);
581
+            $table->addColumn('type', 'string', [
582
+                'notnull' => true,
583
+                'length' => 64,
584
+                'default' => '',
585
+            ]);
586
+            $table->addColumn('category', 'string', [
587
+                'notnull' => true,
588
+                'length' => 255,
589
+                'default' => '',
590
+            ]);
591
+            $table->setPrimaryKey(['id']);
592
+            $table->addIndex(['uid'], 'uid_index');
593
+            $table->addIndex(['type'], 'type_index');
594
+            $table->addIndex(['category'], 'category_index');
595
+        }
596
+
597
+        if (!$schema->hasTable('vcategory_to_object')) {
598
+            $table = $schema->createTable('vcategory_to_object');
599
+            $table->addColumn('objid', 'integer', [
600
+                'notnull' => true,
601
+                'length' => 4,
602
+                'default' => 0,
603
+                'unsigned' => true,
604
+            ]);
605
+            $table->addColumn('categoryid', 'integer', [
606
+                'notnull' => true,
607
+                'length' => 4,
608
+                'default' => 0,
609
+                'unsigned' => true,
610
+            ]);
611
+            $table->addColumn('type', 'string', [
612
+                'notnull' => true,
613
+                'length' => 64,
614
+                'default' => '',
615
+            ]);
616
+            $table->setPrimaryKey(['categoryid', 'objid', 'type']);
617
+            $table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
618
+        }
619
+
620
+        if (!$schema->hasTable('systemtag')) {
621
+            $table = $schema->createTable('systemtag');
622
+            $table->addColumn('id', 'integer', [
623
+                'autoincrement' => true,
624
+                'notnull' => true,
625
+                'length' => 4,
626
+                'unsigned' => true,
627
+            ]);
628
+            $table->addColumn('name', 'string', [
629
+                'notnull' => true,
630
+                'length' => 64,
631
+                'default' => '',
632
+            ]);
633
+            $table->addColumn('visibility', 'smallint', [
634
+                'notnull' => true,
635
+                'length' => 1,
636
+                'default' => 1,
637
+            ]);
638
+            $table->addColumn('editable', 'smallint', [
639
+                'notnull' => true,
640
+                'length' => 1,
641
+                'default' => 1,
642
+            ]);
643
+            $table->setPrimaryKey(['id']);
644
+            $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
645
+        }
646
+
647
+        if (!$schema->hasTable('systemtag_object_mapping')) {
648
+            $table = $schema->createTable('systemtag_object_mapping');
649
+            $table->addColumn('objectid', 'string', [
650
+                'notnull' => true,
651
+                'length' => 64,
652
+                'default' => '',
653
+            ]);
654
+            $table->addColumn('objecttype', 'string', [
655
+                'notnull' => true,
656
+                'length' => 64,
657
+                'default' => '',
658
+            ]);
659
+            $table->addColumn('systemtagid', 'integer', [
660
+                'notnull' => true,
661
+                'length' => 4,
662
+                'default' => 0,
663
+                'unsigned' => true,
664
+            ]);
665
+            $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
666
+        }
667
+
668
+        if (!$schema->hasTable('systemtag_group')) {
669
+            $table = $schema->createTable('systemtag_group');
670
+            $table->addColumn('systemtagid', 'integer', [
671
+                'notnull' => true,
672
+                'length' => 4,
673
+                'default' => 0,
674
+                'unsigned' => true,
675
+            ]);
676
+            $table->addColumn('gid', 'string', [
677
+                'notnull' => true,
678
+            ]);
679
+            $table->setPrimaryKey(['gid', 'systemtagid']);
680
+        }
681
+
682
+        if (!$schema->hasTable('file_locks')) {
683
+            $table = $schema->createTable('file_locks');
684
+            $table->addColumn('id', 'integer', [
685
+                'autoincrement' => true,
686
+                'notnull' => true,
687
+                'length' => 4,
688
+                'unsigned' => true,
689
+            ]);
690
+            $table->addColumn('lock', 'integer', [
691
+                'notnull' => true,
692
+                'length' => 4,
693
+                'default' => 0,
694
+            ]);
695
+            $table->addColumn('key', 'string', [
696
+                'notnull' => true,
697
+                'length' => 64,
698
+            ]);
699
+            $table->addColumn('ttl', 'integer', [
700
+                'notnull' => true,
701
+                'length' => 4,
702
+                'default' => -1,
703
+            ]);
704
+            $table->setPrimaryKey(['id']);
705
+            $table->addUniqueIndex(['key'], 'lock_key_index');
706
+            $table->addIndex(['ttl'], 'lock_ttl_index');
707
+        }
708
+
709
+        if (!$schema->hasTable('comments')) {
710
+            $table = $schema->createTable('comments');
711
+            $table->addColumn('id', 'integer', [
712
+                'autoincrement' => true,
713
+                'notnull' => true,
714
+                'length' => 4,
715
+                'unsigned' => true,
716
+            ]);
717
+            $table->addColumn('parent_id', 'integer', [
718
+                'notnull' => true,
719
+                'length' => 4,
720
+                'default' => 0,
721
+                'unsigned' => true,
722
+            ]);
723
+            $table->addColumn('topmost_parent_id', 'integer', [
724
+                'notnull' => true,
725
+                'length' => 4,
726
+                'default' => 0,
727
+                'unsigned' => true,
728
+            ]);
729
+            $table->addColumn('children_count', 'integer', [
730
+                'notnull' => true,
731
+                'length' => 4,
732
+                'default' => 0,
733
+                'unsigned' => true,
734
+            ]);
735
+            $table->addColumn('actor_type', 'string', [
736
+                'notnull' => true,
737
+                'length' => 64,
738
+                'default' => '',
739
+            ]);
740
+            $table->addColumn('actor_id', 'string', [
741
+                'notnull' => true,
742
+                'length' => 64,
743
+                'default' => '',
744
+            ]);
745
+            $table->addColumn('message', 'text', [
746
+                'notnull' => false,
747
+            ]);
748
+            $table->addColumn('verb', 'string', [
749
+                'notnull' => false,
750
+                'length' => 64,
751
+            ]);
752
+            $table->addColumn('creation_timestamp', 'datetime', [
753
+                'notnull' => false,
754
+            ]);
755
+            $table->addColumn('latest_child_timestamp', 'datetime', [
756
+                'notnull' => false,
757
+            ]);
758
+            $table->addColumn('object_type', 'string', [
759
+                'notnull' => true,
760
+                'length' => 64,
761
+                'default' => '',
762
+            ]);
763
+            $table->addColumn('object_id', 'string', [
764
+                'notnull' => true,
765
+                'length' => 64,
766
+                'default' => '',
767
+            ]);
768
+            $table->setPrimaryKey(['id']);
769
+            $table->addIndex(['parent_id'], 'comments_parent_id_index');
770
+            $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
771
+            $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
772
+            $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
773
+        }
774
+
775
+        if (!$schema->hasTable('comments_read_markers')) {
776
+            $table = $schema->createTable('comments_read_markers');
777
+            $table->addColumn('user_id', 'string', [
778
+                'notnull' => true,
779
+                'length' => 64,
780
+                'default' => '',
781
+            ]);
782
+            $table->addColumn('marker_datetime', 'datetime', [
783
+                'notnull' => false,
784
+            ]);
785
+            $table->addColumn('object_type', 'string', [
786
+                'notnull' => true,
787
+                'length' => 64,
788
+                'default' => '',
789
+            ]);
790
+            $table->addColumn('object_id', 'string', [
791
+                'notnull' => true,
792
+                'length' => 64,
793
+                'default' => '',
794
+            ]);
795
+            $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
796
+            $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
797
+        }
798
+
799
+        if (!$schema->hasTable('credentials')) {
800
+            $table = $schema->createTable('credentials');
801
+            $table->addColumn('user', 'string', [
802
+                'notnull' => true,
803
+                'length' => 64,
804
+            ]);
805
+            $table->addColumn('identifier', 'string', [
806
+                'notnull' => true,
807
+                'length' => 64,
808
+            ]);
809
+            $table->addColumn('credentials', 'text', [
810
+                'notnull' => false,
811
+            ]);
812
+            $table->setPrimaryKey(['user', 'identifier']);
813
+            $table->addIndex(['user'], 'credentials_user');
814
+        }
815
+
816
+        if (!$schema->hasTable('admin_sections')) {
817
+            $table = $schema->createTable('admin_sections');
818
+            $table->addColumn('id', 'string', [
819
+                'notnull' => true,
820
+                'length' => 64,
821
+            ]);
822
+            $table->addColumn('class', 'string', [
823
+                'notnull' => true,
824
+                'length' => 255,
825
+                'default' => '',
826
+            ]);
827
+            $table->addColumn('priority', 'smallint', [
828
+                'notnull' => true,
829
+                'length' => 1,
830
+                'default' => 0,
831
+            ]);
832
+            $table->setPrimaryKey(['id']);
833
+            $table->addUniqueIndex(['class'], 'admin_sections_class');
834
+        }
835
+
836
+        if (!$schema->hasTable('admin_settings')) {
837
+            $table = $schema->createTable('admin_settings');
838
+            $table->addColumn('id', 'integer', [
839
+                'autoincrement' => true,
840
+                'notnull' => true,
841
+                'length' => 4,
842
+            ]);
843
+            $table->addColumn('class', 'string', [
844
+                'notnull' => true,
845
+                'length' => 255,
846
+                'default' => '',
847
+            ]);
848
+            $table->addColumn('section', 'string', [
849
+                'notnull' => false,
850
+                'length' => 64,
851
+            ]);
852
+            $table->addColumn('priority', 'smallint', [
853
+                'notnull' => true,
854
+                'length' => 1,
855
+                'default' => 0,
856
+            ]);
857
+            $table->setPrimaryKey(['id']);
858
+            $table->addUniqueIndex(['class'], 'admin_settings_class');
859
+            $table->addIndex(['section'], 'admin_settings_section');
860
+        }
861
+
862
+        if (!$schema->hasTable('personal_sections')) {
863
+            $table = $schema->createTable('personal_sections');
864
+            $table->addColumn('id', 'string', [
865
+                'notnull' => true,
866
+                'length' => 64,
867
+            ]);
868
+            $table->addColumn('class', 'string', [
869
+                'notnull' => true,
870
+                'length' => 255,
871
+                'default' => '',
872
+            ]);
873
+            $table->addColumn('priority', 'smallint', [
874
+                'notnull' => true,
875
+                'length' => 1,
876
+                'default' => 0,
877
+            ]);
878
+            $table->setPrimaryKey(['id']);
879
+            $table->addUniqueIndex(['class'], 'personal_sections_class');
880
+        }
881
+
882
+        if (!$schema->hasTable('personal_settings')) {
883
+            $table = $schema->createTable('personal_settings');
884
+            $table->addColumn('id', 'integer', [
885
+                'autoincrement' => true,
886
+                'notnull' => true,
887
+                'length' => 4,
888
+            ]);
889
+            $table->addColumn('class', 'string', [
890
+                'notnull' => true,
891
+                'length' => 255,
892
+                'default' => '',
893
+            ]);
894
+            $table->addColumn('section', 'string', [
895
+                'notnull' => false,
896
+                'length' => 64,
897
+            ]);
898
+            $table->addColumn('priority', 'smallint', [
899
+                'notnull' => true,
900
+                'length' => 1,
901
+                'default' => 0,
902
+            ]);
903
+            $table->setPrimaryKey(['id']);
904
+            $table->addUniqueIndex(['class'], 'personal_settings_class');
905
+            $table->addIndex(['section'], 'personal_settings_section');
906
+        }
907
+
908
+        if (!$schema->hasTable('accounts')) {
909
+            $table = $schema->createTable('accounts');
910
+            $table->addColumn('uid', 'string', [
911
+                'notnull' => true,
912
+                'length' => 64,
913
+                'default' => '',
914
+            ]);
915
+            $table->addColumn('data', 'text', [
916
+                'notnull' => true,
917
+                'default' => '',
918
+            ]);
919
+            $table->setPrimaryKey(['uid']);
920
+        }
921
+        return $schema;
922
+    }
923 923
 
924 924
 }
Please login to merge, or discard this patch.