Completed
Push — master ( 4751f1...b03366 )
by Morris
27:52 queued 12:19
created
core/Migrations/Version13000Date20170718121200.php 1 patch
Indentation   +888 added lines, -888 removed lines patch added patch discarded remove patch
@@ -30,893 +30,893 @@
 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
-			$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
-		}
407
-
408
-		if (!$schema->hasTable('jobs')) {
409
-			$table = $schema->createTable('jobs');
410
-			$table->addColumn('id', 'integer', [
411
-				'autoincrement' => true,
412
-				'notnull' => true,
413
-				'length' => 4,
414
-				'unsigned' => true,
415
-			]);
416
-			$table->addColumn('class', 'string', [
417
-				'notnull' => true,
418
-				'length' => 255,
419
-				'default' => '',
420
-			]);
421
-			$table->addColumn('argument', 'string', [
422
-				'notnull' => true,
423
-				'length' => 4000,
424
-				'default' => '',
425
-			]);
426
-			$table->addColumn('last_run', 'integer', [
427
-				'notnull' => false,
428
-				'default' => 0,
429
-			]);
430
-			$table->addColumn('last_checked', 'integer', [
431
-				'notnull' => false,
432
-				'default' => 0,
433
-			]);
434
-			$table->addColumn('reserved_at', 'integer', [
435
-				'notnull' => false,
436
-				'default' => 0,
437
-			]);
438
-			$table->addColumn('execution_duration', 'integer', [
439
-				'notnull' => true,
440
-				'default' => 0,
441
-			]);
442
-			$table->setPrimaryKey(['id']);
443
-			$table->addIndex(['class'], 'job_class_index');
444
-		}
445
-
446
-		if (!$schema->hasTable('users')) {
447
-			$table = $schema->createTable('users');
448
-			$table->addColumn('uid', 'string', [
449
-				'notnull' => true,
450
-				'length' => 64,
451
-				'default' => '',
452
-			]);
453
-			$table->addColumn('displayname', 'string', [
454
-				'notnull' => false,
455
-				'length' => 64,
456
-			]);
457
-			$table->addColumn('password', 'string', [
458
-				'notnull' => true,
459
-				'length' => 255,
460
-				'default' => '',
461
-			]);
462
-			$table->setPrimaryKey(['uid']);
463
-		}
464
-
465
-		if (!$schema->hasTable('authtoken')) {
466
-			$table = $schema->createTable('authtoken');
467
-			$table->addColumn('id', 'integer', [
468
-				'autoincrement' => true,
469
-				'notnull' => true,
470
-				'length' => 4,
471
-				'unsigned' => true,
472
-			]);
473
-			$table->addColumn('uid', 'string', [
474
-				'notnull' => true,
475
-				'length' => 64,
476
-				'default' => '',
477
-			]);
478
-			$table->addColumn('login_name', 'string', [
479
-				'notnull' => true,
480
-				'length' => 64,
481
-				'default' => '',
482
-			]);
483
-			$table->addColumn('password', 'text', [
484
-				'notnull' => false,
485
-			]);
486
-			$table->addColumn('name', 'text', [
487
-				'notnull' => true,
488
-				'default' => '',
489
-			]);
490
-			$table->addColumn('token', 'string', [
491
-				'notnull' => true,
492
-				'length' => 200,
493
-				'default' => '',
494
-			]);
495
-			$table->addColumn('type', 'smallint', [
496
-				'notnull' => true,
497
-				'length' => 2,
498
-				'default' => 0,
499
-				'unsigned' => true,
500
-			]);
501
-			$table->addColumn('remember', 'smallint', [
502
-				'notnull' => true,
503
-				'length' => 1,
504
-				'default' => 0,
505
-				'unsigned' => true,
506
-			]);
507
-			$table->addColumn('last_activity', 'integer', [
508
-				'notnull' => true,
509
-				'length' => 4,
510
-				'default' => 0,
511
-				'unsigned' => true,
512
-			]);
513
-			$table->addColumn('last_check', 'integer', [
514
-				'notnull' => true,
515
-				'length' => 4,
516
-				'default' => 0,
517
-				'unsigned' => true,
518
-			]);
519
-			$table->addColumn('scope', 'text', [
520
-				'notnull' => false,
521
-			]);
522
-			$table->setPrimaryKey(['id']);
523
-			$table->addUniqueIndex(['token'], 'authtoken_token_index');
524
-			$table->addIndex(['last_activity'], 'authtoken_last_activity_index');
525
-		}
526
-
527
-		if (!$schema->hasTable('bruteforce_attempts')) {
528
-			$table = $schema->createTable('bruteforce_attempts');
529
-			$table->addColumn('id', 'integer', [
530
-				'autoincrement' => true,
531
-				'notnull' => true,
532
-				'length' => 4,
533
-				'unsigned' => true,
534
-			]);
535
-			$table->addColumn('action', 'string', [
536
-				'notnull' => true,
537
-				'length' => 64,
538
-				'default' => '',
539
-			]);
540
-			$table->addColumn('occurred', 'integer', [
541
-				'notnull' => true,
542
-				'length' => 4,
543
-				'default' => 0,
544
-				'unsigned' => true,
545
-			]);
546
-			$table->addColumn('ip', 'string', [
547
-				'notnull' => true,
548
-				'length' => 255,
549
-				'default' => '',
550
-			]);
551
-			$table->addColumn('subnet', 'string', [
552
-				'notnull' => true,
553
-				'length' => 255,
554
-				'default' => '',
555
-			]);
556
-			$table->addColumn('metadata', 'string', [
557
-				'notnull' => true,
558
-				'length' => 255,
559
-				'default' => '',
560
-			]);
561
-			$table->setPrimaryKey(['id']);
562
-			$table->addIndex(['ip'], 'bruteforce_attempts_ip');
563
-			$table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
564
-		}
565
-
566
-		if (!$schema->hasTable('vcategory')) {
567
-			$table = $schema->createTable('vcategory');
568
-			$table->addColumn('id', 'integer', [
569
-				'autoincrement' => true,
570
-				'notnull' => true,
571
-				'length' => 4,
572
-				'unsigned' => true,
573
-			]);
574
-			$table->addColumn('uid', 'string', [
575
-				'notnull' => true,
576
-				'length' => 64,
577
-				'default' => '',
578
-			]);
579
-			$table->addColumn('type', 'string', [
580
-				'notnull' => true,
581
-				'length' => 64,
582
-				'default' => '',
583
-			]);
584
-			$table->addColumn('category', 'string', [
585
-				'notnull' => true,
586
-				'length' => 255,
587
-				'default' => '',
588
-			]);
589
-			$table->setPrimaryKey(['id']);
590
-			$table->addIndex(['uid'], 'uid_index');
591
-			$table->addIndex(['type'], 'type_index');
592
-			$table->addIndex(['category'], 'category_index');
593
-		}
594
-
595
-		if (!$schema->hasTable('vcategory_to_object')) {
596
-			$table = $schema->createTable('vcategory_to_object');
597
-			$table->addColumn('objid', 'integer', [
598
-				'notnull' => true,
599
-				'length' => 4,
600
-				'default' => 0,
601
-				'unsigned' => true,
602
-			]);
603
-			$table->addColumn('categoryid', 'integer', [
604
-				'notnull' => true,
605
-				'length' => 4,
606
-				'default' => 0,
607
-				'unsigned' => true,
608
-			]);
609
-			$table->addColumn('type', 'string', [
610
-				'notnull' => true,
611
-				'length' => 64,
612
-				'default' => '',
613
-			]);
614
-			$table->setPrimaryKey(['categoryid', 'objid', 'type']);
615
-			$table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
616
-		}
617
-
618
-		if (!$schema->hasTable('systemtag')) {
619
-			$table = $schema->createTable('systemtag');
620
-			$table->addColumn('id', 'integer', [
621
-				'autoincrement' => true,
622
-				'notnull' => true,
623
-				'length' => 4,
624
-				'unsigned' => true,
625
-			]);
626
-			$table->addColumn('name', 'string', [
627
-				'notnull' => true,
628
-				'length' => 64,
629
-				'default' => '',
630
-			]);
631
-			$table->addColumn('visibility', 'smallint', [
632
-				'notnull' => true,
633
-				'length' => 1,
634
-				'default' => 1,
635
-			]);
636
-			$table->addColumn('editable', 'smallint', [
637
-				'notnull' => true,
638
-				'length' => 1,
639
-				'default' => 1,
640
-			]);
641
-			$table->setPrimaryKey(['id']);
642
-			$table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
643
-		}
644
-
645
-		if (!$schema->hasTable('systemtag_object_mapping')) {
646
-			$table = $schema->createTable('systemtag_object_mapping');
647
-			$table->addColumn('objectid', 'string', [
648
-				'notnull' => true,
649
-				'length' => 64,
650
-				'default' => '',
651
-			]);
652
-			$table->addColumn('objecttype', 'string', [
653
-				'notnull' => true,
654
-				'length' => 64,
655
-				'default' => '',
656
-			]);
657
-			$table->addColumn('systemtagid', 'integer', [
658
-				'notnull' => true,
659
-				'length' => 4,
660
-				'default' => 0,
661
-				'unsigned' => true,
662
-			]);
663
-			$table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
664
-		}
665
-
666
-		if (!$schema->hasTable('systemtag_group')) {
667
-			$table = $schema->createTable('systemtag_group');
668
-			$table->addColumn('systemtagid', 'integer', [
669
-				'notnull' => true,
670
-				'length' => 4,
671
-				'default' => 0,
672
-				'unsigned' => true,
673
-			]);
674
-			$table->addColumn('gid', 'string', [
675
-				'notnull' => true,
676
-			]);
677
-			$table->setPrimaryKey(['gid', 'systemtagid']);
678
-		}
679
-
680
-		if (!$schema->hasTable('file_locks')) {
681
-			$table = $schema->createTable('file_locks');
682
-			$table->addColumn('id', 'integer', [
683
-				'autoincrement' => true,
684
-				'notnull' => true,
685
-				'length' => 4,
686
-				'unsigned' => true,
687
-			]);
688
-			$table->addColumn('lock', 'integer', [
689
-				'notnull' => true,
690
-				'length' => 4,
691
-				'default' => 0,
692
-			]);
693
-			$table->addColumn('key', 'string', [
694
-				'notnull' => true,
695
-				'length' => 64,
696
-			]);
697
-			$table->addColumn('ttl', 'integer', [
698
-				'notnull' => true,
699
-				'length' => 4,
700
-				'default' => -1,
701
-			]);
702
-			$table->setPrimaryKey(['id']);
703
-			$table->addUniqueIndex(['key'], 'lock_key_index');
704
-			$table->addIndex(['ttl'], 'lock_ttl_index');
705
-		}
706
-
707
-		if (!$schema->hasTable('comments')) {
708
-			$table = $schema->createTable('comments');
709
-			$table->addColumn('id', 'integer', [
710
-				'autoincrement' => true,
711
-				'notnull' => true,
712
-				'length' => 4,
713
-				'unsigned' => true,
714
-			]);
715
-			$table->addColumn('parent_id', 'integer', [
716
-				'notnull' => true,
717
-				'length' => 4,
718
-				'default' => 0,
719
-				'unsigned' => true,
720
-			]);
721
-			$table->addColumn('topmost_parent_id', 'integer', [
722
-				'notnull' => true,
723
-				'length' => 4,
724
-				'default' => 0,
725
-				'unsigned' => true,
726
-			]);
727
-			$table->addColumn('children_count', 'integer', [
728
-				'notnull' => true,
729
-				'length' => 4,
730
-				'default' => 0,
731
-				'unsigned' => true,
732
-			]);
733
-			$table->addColumn('actor_type', 'string', [
734
-				'notnull' => true,
735
-				'length' => 64,
736
-				'default' => '',
737
-			]);
738
-			$table->addColumn('actor_id', 'string', [
739
-				'notnull' => true,
740
-				'length' => 64,
741
-				'default' => '',
742
-			]);
743
-			$table->addColumn('message', 'text', [
744
-				'notnull' => false,
745
-			]);
746
-			$table->addColumn('verb', 'string', [
747
-				'notnull' => false,
748
-				'length' => 64,
749
-			]);
750
-			$table->addColumn('creation_timestamp', 'datetime', [
751
-				'notnull' => false,
752
-			]);
753
-			$table->addColumn('latest_child_timestamp', 'datetime', [
754
-				'notnull' => false,
755
-			]);
756
-			$table->addColumn('object_type', 'string', [
757
-				'notnull' => true,
758
-				'length' => 64,
759
-				'default' => '',
760
-			]);
761
-			$table->addColumn('object_id', 'string', [
762
-				'notnull' => true,
763
-				'length' => 64,
764
-				'default' => '',
765
-			]);
766
-			$table->setPrimaryKey(['id']);
767
-			$table->addIndex(['parent_id'], 'comments_parent_id_index');
768
-			$table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
769
-			$table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
770
-			$table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
771
-		}
772
-
773
-		if (!$schema->hasTable('comments_read_markers')) {
774
-			$table = $schema->createTable('comments_read_markers');
775
-			$table->addColumn('user_id', 'string', [
776
-				'notnull' => true,
777
-				'length' => 64,
778
-				'default' => '',
779
-			]);
780
-			$table->addColumn('marker_datetime', 'datetime', [
781
-				'notnull' => false,
782
-			]);
783
-			$table->addColumn('object_type', 'string', [
784
-				'notnull' => true,
785
-				'length' => 64,
786
-				'default' => '',
787
-			]);
788
-			$table->addColumn('object_id', 'string', [
789
-				'notnull' => true,
790
-				'length' => 64,
791
-				'default' => '',
792
-			]);
793
-			$table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
794
-			$table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
795
-		}
796
-
797
-		if (!$schema->hasTable('credentials')) {
798
-			$table = $schema->createTable('credentials');
799
-			$table->addColumn('user', 'string', [
800
-				'notnull' => true,
801
-				'length' => 64,
802
-			]);
803
-			$table->addColumn('identifier', 'string', [
804
-				'notnull' => true,
805
-				'length' => 64,
806
-			]);
807
-			$table->addColumn('credentials', 'text', [
808
-				'notnull' => false,
809
-			]);
810
-			$table->setPrimaryKey(['user', 'identifier']);
811
-			$table->addIndex(['user'], 'credentials_user');
812
-		}
813
-
814
-		if (!$schema->hasTable('admin_sections')) {
815
-			$table = $schema->createTable('admin_sections');
816
-			$table->addColumn('id', 'string', [
817
-				'notnull' => true,
818
-				'length' => 64,
819
-			]);
820
-			$table->addColumn('class', 'string', [
821
-				'notnull' => true,
822
-				'length' => 255,
823
-				'default' => '',
824
-			]);
825
-			$table->addColumn('priority', 'smallint', [
826
-				'notnull' => true,
827
-				'length' => 1,
828
-				'default' => 0,
829
-			]);
830
-			$table->setPrimaryKey(['id']);
831
-			$table->addUniqueIndex(['class'], 'admin_sections_class');
832
-		}
833
-
834
-		if (!$schema->hasTable('admin_settings')) {
835
-			$table = $schema->createTable('admin_settings');
836
-			$table->addColumn('id', 'integer', [
837
-				'autoincrement' => true,
838
-				'notnull' => true,
839
-				'length' => 4,
840
-			]);
841
-			$table->addColumn('class', 'string', [
842
-				'notnull' => true,
843
-				'length' => 255,
844
-				'default' => '',
845
-			]);
846
-			$table->addColumn('section', 'string', [
847
-				'notnull' => false,
848
-				'length' => 64,
849
-			]);
850
-			$table->addColumn('priority', 'smallint', [
851
-				'notnull' => true,
852
-				'length' => 1,
853
-				'default' => 0,
854
-			]);
855
-			$table->setPrimaryKey(['id']);
856
-			$table->addUniqueIndex(['class'], 'admin_settings_class');
857
-			$table->addIndex(['section'], 'admin_settings_section');
858
-		}
859
-
860
-		if (!$schema->hasTable('personal_sections')) {
861
-			$table = $schema->createTable('personal_sections');
862
-			$table->addColumn('id', 'string', [
863
-				'notnull' => true,
864
-				'length' => 64,
865
-			]);
866
-			$table->addColumn('class', 'string', [
867
-				'notnull' => true,
868
-				'length' => 255,
869
-				'default' => '',
870
-			]);
871
-			$table->addColumn('priority', 'smallint', [
872
-				'notnull' => true,
873
-				'length' => 1,
874
-				'default' => 0,
875
-			]);
876
-			$table->setPrimaryKey(['id']);
877
-			$table->addUniqueIndex(['class'], 'personal_sections_class');
878
-		}
879
-
880
-		if (!$schema->hasTable('personal_settings')) {
881
-			$table = $schema->createTable('personal_settings');
882
-			$table->addColumn('id', 'integer', [
883
-				'autoincrement' => true,
884
-				'notnull' => true,
885
-				'length' => 4,
886
-			]);
887
-			$table->addColumn('class', 'string', [
888
-				'notnull' => true,
889
-				'length' => 255,
890
-				'default' => '',
891
-			]);
892
-			$table->addColumn('section', 'string', [
893
-				'notnull' => false,
894
-				'length' => 64,
895
-			]);
896
-			$table->addColumn('priority', 'smallint', [
897
-				'notnull' => true,
898
-				'length' => 1,
899
-				'default' => 0,
900
-			]);
901
-			$table->setPrimaryKey(['id']);
902
-			$table->addUniqueIndex(['class'], 'personal_settings_class');
903
-			$table->addIndex(['section'], 'personal_settings_section');
904
-		}
905
-
906
-		if (!$schema->hasTable('accounts')) {
907
-			$table = $schema->createTable('accounts');
908
-			$table->addColumn('uid', 'string', [
909
-				'notnull' => true,
910
-				'length' => 64,
911
-				'default' => '',
912
-			]);
913
-			$table->addColumn('data', 'text', [
914
-				'notnull' => true,
915
-				'default' => '',
916
-			]);
917
-			$table->setPrimaryKey(['uid']);
918
-		}
919
-		return $schema;
920
-	}
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
+            $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
+        }
407
+
408
+        if (!$schema->hasTable('jobs')) {
409
+            $table = $schema->createTable('jobs');
410
+            $table->addColumn('id', 'integer', [
411
+                'autoincrement' => true,
412
+                'notnull' => true,
413
+                'length' => 4,
414
+                'unsigned' => true,
415
+            ]);
416
+            $table->addColumn('class', 'string', [
417
+                'notnull' => true,
418
+                'length' => 255,
419
+                'default' => '',
420
+            ]);
421
+            $table->addColumn('argument', 'string', [
422
+                'notnull' => true,
423
+                'length' => 4000,
424
+                'default' => '',
425
+            ]);
426
+            $table->addColumn('last_run', 'integer', [
427
+                'notnull' => false,
428
+                'default' => 0,
429
+            ]);
430
+            $table->addColumn('last_checked', 'integer', [
431
+                'notnull' => false,
432
+                'default' => 0,
433
+            ]);
434
+            $table->addColumn('reserved_at', 'integer', [
435
+                'notnull' => false,
436
+                'default' => 0,
437
+            ]);
438
+            $table->addColumn('execution_duration', 'integer', [
439
+                'notnull' => true,
440
+                'default' => 0,
441
+            ]);
442
+            $table->setPrimaryKey(['id']);
443
+            $table->addIndex(['class'], 'job_class_index');
444
+        }
445
+
446
+        if (!$schema->hasTable('users')) {
447
+            $table = $schema->createTable('users');
448
+            $table->addColumn('uid', 'string', [
449
+                'notnull' => true,
450
+                'length' => 64,
451
+                'default' => '',
452
+            ]);
453
+            $table->addColumn('displayname', 'string', [
454
+                'notnull' => false,
455
+                'length' => 64,
456
+            ]);
457
+            $table->addColumn('password', 'string', [
458
+                'notnull' => true,
459
+                'length' => 255,
460
+                'default' => '',
461
+            ]);
462
+            $table->setPrimaryKey(['uid']);
463
+        }
464
+
465
+        if (!$schema->hasTable('authtoken')) {
466
+            $table = $schema->createTable('authtoken');
467
+            $table->addColumn('id', 'integer', [
468
+                'autoincrement' => true,
469
+                'notnull' => true,
470
+                'length' => 4,
471
+                'unsigned' => true,
472
+            ]);
473
+            $table->addColumn('uid', 'string', [
474
+                'notnull' => true,
475
+                'length' => 64,
476
+                'default' => '',
477
+            ]);
478
+            $table->addColumn('login_name', 'string', [
479
+                'notnull' => true,
480
+                'length' => 64,
481
+                'default' => '',
482
+            ]);
483
+            $table->addColumn('password', 'text', [
484
+                'notnull' => false,
485
+            ]);
486
+            $table->addColumn('name', 'text', [
487
+                'notnull' => true,
488
+                'default' => '',
489
+            ]);
490
+            $table->addColumn('token', 'string', [
491
+                'notnull' => true,
492
+                'length' => 200,
493
+                'default' => '',
494
+            ]);
495
+            $table->addColumn('type', 'smallint', [
496
+                'notnull' => true,
497
+                'length' => 2,
498
+                'default' => 0,
499
+                'unsigned' => true,
500
+            ]);
501
+            $table->addColumn('remember', 'smallint', [
502
+                'notnull' => true,
503
+                'length' => 1,
504
+                'default' => 0,
505
+                'unsigned' => true,
506
+            ]);
507
+            $table->addColumn('last_activity', 'integer', [
508
+                'notnull' => true,
509
+                'length' => 4,
510
+                'default' => 0,
511
+                'unsigned' => true,
512
+            ]);
513
+            $table->addColumn('last_check', 'integer', [
514
+                'notnull' => true,
515
+                'length' => 4,
516
+                'default' => 0,
517
+                'unsigned' => true,
518
+            ]);
519
+            $table->addColumn('scope', 'text', [
520
+                'notnull' => false,
521
+            ]);
522
+            $table->setPrimaryKey(['id']);
523
+            $table->addUniqueIndex(['token'], 'authtoken_token_index');
524
+            $table->addIndex(['last_activity'], 'authtoken_last_activity_index');
525
+        }
526
+
527
+        if (!$schema->hasTable('bruteforce_attempts')) {
528
+            $table = $schema->createTable('bruteforce_attempts');
529
+            $table->addColumn('id', 'integer', [
530
+                'autoincrement' => true,
531
+                'notnull' => true,
532
+                'length' => 4,
533
+                'unsigned' => true,
534
+            ]);
535
+            $table->addColumn('action', 'string', [
536
+                'notnull' => true,
537
+                'length' => 64,
538
+                'default' => '',
539
+            ]);
540
+            $table->addColumn('occurred', 'integer', [
541
+                'notnull' => true,
542
+                'length' => 4,
543
+                'default' => 0,
544
+                'unsigned' => true,
545
+            ]);
546
+            $table->addColumn('ip', 'string', [
547
+                'notnull' => true,
548
+                'length' => 255,
549
+                'default' => '',
550
+            ]);
551
+            $table->addColumn('subnet', 'string', [
552
+                'notnull' => true,
553
+                'length' => 255,
554
+                'default' => '',
555
+            ]);
556
+            $table->addColumn('metadata', 'string', [
557
+                'notnull' => true,
558
+                'length' => 255,
559
+                'default' => '',
560
+            ]);
561
+            $table->setPrimaryKey(['id']);
562
+            $table->addIndex(['ip'], 'bruteforce_attempts_ip');
563
+            $table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
564
+        }
565
+
566
+        if (!$schema->hasTable('vcategory')) {
567
+            $table = $schema->createTable('vcategory');
568
+            $table->addColumn('id', 'integer', [
569
+                'autoincrement' => true,
570
+                'notnull' => true,
571
+                'length' => 4,
572
+                'unsigned' => true,
573
+            ]);
574
+            $table->addColumn('uid', 'string', [
575
+                'notnull' => true,
576
+                'length' => 64,
577
+                'default' => '',
578
+            ]);
579
+            $table->addColumn('type', 'string', [
580
+                'notnull' => true,
581
+                'length' => 64,
582
+                'default' => '',
583
+            ]);
584
+            $table->addColumn('category', 'string', [
585
+                'notnull' => true,
586
+                'length' => 255,
587
+                'default' => '',
588
+            ]);
589
+            $table->setPrimaryKey(['id']);
590
+            $table->addIndex(['uid'], 'uid_index');
591
+            $table->addIndex(['type'], 'type_index');
592
+            $table->addIndex(['category'], 'category_index');
593
+        }
594
+
595
+        if (!$schema->hasTable('vcategory_to_object')) {
596
+            $table = $schema->createTable('vcategory_to_object');
597
+            $table->addColumn('objid', 'integer', [
598
+                'notnull' => true,
599
+                'length' => 4,
600
+                'default' => 0,
601
+                'unsigned' => true,
602
+            ]);
603
+            $table->addColumn('categoryid', 'integer', [
604
+                'notnull' => true,
605
+                'length' => 4,
606
+                'default' => 0,
607
+                'unsigned' => true,
608
+            ]);
609
+            $table->addColumn('type', 'string', [
610
+                'notnull' => true,
611
+                'length' => 64,
612
+                'default' => '',
613
+            ]);
614
+            $table->setPrimaryKey(['categoryid', 'objid', 'type']);
615
+            $table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
616
+        }
617
+
618
+        if (!$schema->hasTable('systemtag')) {
619
+            $table = $schema->createTable('systemtag');
620
+            $table->addColumn('id', 'integer', [
621
+                'autoincrement' => true,
622
+                'notnull' => true,
623
+                'length' => 4,
624
+                'unsigned' => true,
625
+            ]);
626
+            $table->addColumn('name', 'string', [
627
+                'notnull' => true,
628
+                'length' => 64,
629
+                'default' => '',
630
+            ]);
631
+            $table->addColumn('visibility', 'smallint', [
632
+                'notnull' => true,
633
+                'length' => 1,
634
+                'default' => 1,
635
+            ]);
636
+            $table->addColumn('editable', 'smallint', [
637
+                'notnull' => true,
638
+                'length' => 1,
639
+                'default' => 1,
640
+            ]);
641
+            $table->setPrimaryKey(['id']);
642
+            $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
643
+        }
644
+
645
+        if (!$schema->hasTable('systemtag_object_mapping')) {
646
+            $table = $schema->createTable('systemtag_object_mapping');
647
+            $table->addColumn('objectid', 'string', [
648
+                'notnull' => true,
649
+                'length' => 64,
650
+                'default' => '',
651
+            ]);
652
+            $table->addColumn('objecttype', 'string', [
653
+                'notnull' => true,
654
+                'length' => 64,
655
+                'default' => '',
656
+            ]);
657
+            $table->addColumn('systemtagid', 'integer', [
658
+                'notnull' => true,
659
+                'length' => 4,
660
+                'default' => 0,
661
+                'unsigned' => true,
662
+            ]);
663
+            $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
664
+        }
665
+
666
+        if (!$schema->hasTable('systemtag_group')) {
667
+            $table = $schema->createTable('systemtag_group');
668
+            $table->addColumn('systemtagid', 'integer', [
669
+                'notnull' => true,
670
+                'length' => 4,
671
+                'default' => 0,
672
+                'unsigned' => true,
673
+            ]);
674
+            $table->addColumn('gid', 'string', [
675
+                'notnull' => true,
676
+            ]);
677
+            $table->setPrimaryKey(['gid', 'systemtagid']);
678
+        }
679
+
680
+        if (!$schema->hasTable('file_locks')) {
681
+            $table = $schema->createTable('file_locks');
682
+            $table->addColumn('id', 'integer', [
683
+                'autoincrement' => true,
684
+                'notnull' => true,
685
+                'length' => 4,
686
+                'unsigned' => true,
687
+            ]);
688
+            $table->addColumn('lock', 'integer', [
689
+                'notnull' => true,
690
+                'length' => 4,
691
+                'default' => 0,
692
+            ]);
693
+            $table->addColumn('key', 'string', [
694
+                'notnull' => true,
695
+                'length' => 64,
696
+            ]);
697
+            $table->addColumn('ttl', 'integer', [
698
+                'notnull' => true,
699
+                'length' => 4,
700
+                'default' => -1,
701
+            ]);
702
+            $table->setPrimaryKey(['id']);
703
+            $table->addUniqueIndex(['key'], 'lock_key_index');
704
+            $table->addIndex(['ttl'], 'lock_ttl_index');
705
+        }
706
+
707
+        if (!$schema->hasTable('comments')) {
708
+            $table = $schema->createTable('comments');
709
+            $table->addColumn('id', 'integer', [
710
+                'autoincrement' => true,
711
+                'notnull' => true,
712
+                'length' => 4,
713
+                'unsigned' => true,
714
+            ]);
715
+            $table->addColumn('parent_id', 'integer', [
716
+                'notnull' => true,
717
+                'length' => 4,
718
+                'default' => 0,
719
+                'unsigned' => true,
720
+            ]);
721
+            $table->addColumn('topmost_parent_id', 'integer', [
722
+                'notnull' => true,
723
+                'length' => 4,
724
+                'default' => 0,
725
+                'unsigned' => true,
726
+            ]);
727
+            $table->addColumn('children_count', 'integer', [
728
+                'notnull' => true,
729
+                'length' => 4,
730
+                'default' => 0,
731
+                'unsigned' => true,
732
+            ]);
733
+            $table->addColumn('actor_type', 'string', [
734
+                'notnull' => true,
735
+                'length' => 64,
736
+                'default' => '',
737
+            ]);
738
+            $table->addColumn('actor_id', 'string', [
739
+                'notnull' => true,
740
+                'length' => 64,
741
+                'default' => '',
742
+            ]);
743
+            $table->addColumn('message', 'text', [
744
+                'notnull' => false,
745
+            ]);
746
+            $table->addColumn('verb', 'string', [
747
+                'notnull' => false,
748
+                'length' => 64,
749
+            ]);
750
+            $table->addColumn('creation_timestamp', 'datetime', [
751
+                'notnull' => false,
752
+            ]);
753
+            $table->addColumn('latest_child_timestamp', 'datetime', [
754
+                'notnull' => false,
755
+            ]);
756
+            $table->addColumn('object_type', 'string', [
757
+                'notnull' => true,
758
+                'length' => 64,
759
+                'default' => '',
760
+            ]);
761
+            $table->addColumn('object_id', 'string', [
762
+                'notnull' => true,
763
+                'length' => 64,
764
+                'default' => '',
765
+            ]);
766
+            $table->setPrimaryKey(['id']);
767
+            $table->addIndex(['parent_id'], 'comments_parent_id_index');
768
+            $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
769
+            $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
770
+            $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
771
+        }
772
+
773
+        if (!$schema->hasTable('comments_read_markers')) {
774
+            $table = $schema->createTable('comments_read_markers');
775
+            $table->addColumn('user_id', 'string', [
776
+                'notnull' => true,
777
+                'length' => 64,
778
+                'default' => '',
779
+            ]);
780
+            $table->addColumn('marker_datetime', 'datetime', [
781
+                'notnull' => false,
782
+            ]);
783
+            $table->addColumn('object_type', 'string', [
784
+                'notnull' => true,
785
+                'length' => 64,
786
+                'default' => '',
787
+            ]);
788
+            $table->addColumn('object_id', 'string', [
789
+                'notnull' => true,
790
+                'length' => 64,
791
+                'default' => '',
792
+            ]);
793
+            $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
794
+            $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
795
+        }
796
+
797
+        if (!$schema->hasTable('credentials')) {
798
+            $table = $schema->createTable('credentials');
799
+            $table->addColumn('user', 'string', [
800
+                'notnull' => true,
801
+                'length' => 64,
802
+            ]);
803
+            $table->addColumn('identifier', 'string', [
804
+                'notnull' => true,
805
+                'length' => 64,
806
+            ]);
807
+            $table->addColumn('credentials', 'text', [
808
+                'notnull' => false,
809
+            ]);
810
+            $table->setPrimaryKey(['user', 'identifier']);
811
+            $table->addIndex(['user'], 'credentials_user');
812
+        }
813
+
814
+        if (!$schema->hasTable('admin_sections')) {
815
+            $table = $schema->createTable('admin_sections');
816
+            $table->addColumn('id', 'string', [
817
+                'notnull' => true,
818
+                'length' => 64,
819
+            ]);
820
+            $table->addColumn('class', 'string', [
821
+                'notnull' => true,
822
+                'length' => 255,
823
+                'default' => '',
824
+            ]);
825
+            $table->addColumn('priority', 'smallint', [
826
+                'notnull' => true,
827
+                'length' => 1,
828
+                'default' => 0,
829
+            ]);
830
+            $table->setPrimaryKey(['id']);
831
+            $table->addUniqueIndex(['class'], 'admin_sections_class');
832
+        }
833
+
834
+        if (!$schema->hasTable('admin_settings')) {
835
+            $table = $schema->createTable('admin_settings');
836
+            $table->addColumn('id', 'integer', [
837
+                'autoincrement' => true,
838
+                'notnull' => true,
839
+                'length' => 4,
840
+            ]);
841
+            $table->addColumn('class', 'string', [
842
+                'notnull' => true,
843
+                'length' => 255,
844
+                'default' => '',
845
+            ]);
846
+            $table->addColumn('section', 'string', [
847
+                'notnull' => false,
848
+                'length' => 64,
849
+            ]);
850
+            $table->addColumn('priority', 'smallint', [
851
+                'notnull' => true,
852
+                'length' => 1,
853
+                'default' => 0,
854
+            ]);
855
+            $table->setPrimaryKey(['id']);
856
+            $table->addUniqueIndex(['class'], 'admin_settings_class');
857
+            $table->addIndex(['section'], 'admin_settings_section');
858
+        }
859
+
860
+        if (!$schema->hasTable('personal_sections')) {
861
+            $table = $schema->createTable('personal_sections');
862
+            $table->addColumn('id', 'string', [
863
+                'notnull' => true,
864
+                'length' => 64,
865
+            ]);
866
+            $table->addColumn('class', 'string', [
867
+                'notnull' => true,
868
+                'length' => 255,
869
+                'default' => '',
870
+            ]);
871
+            $table->addColumn('priority', 'smallint', [
872
+                'notnull' => true,
873
+                'length' => 1,
874
+                'default' => 0,
875
+            ]);
876
+            $table->setPrimaryKey(['id']);
877
+            $table->addUniqueIndex(['class'], 'personal_sections_class');
878
+        }
879
+
880
+        if (!$schema->hasTable('personal_settings')) {
881
+            $table = $schema->createTable('personal_settings');
882
+            $table->addColumn('id', 'integer', [
883
+                'autoincrement' => true,
884
+                'notnull' => true,
885
+                'length' => 4,
886
+            ]);
887
+            $table->addColumn('class', 'string', [
888
+                'notnull' => true,
889
+                'length' => 255,
890
+                'default' => '',
891
+            ]);
892
+            $table->addColumn('section', 'string', [
893
+                'notnull' => false,
894
+                'length' => 64,
895
+            ]);
896
+            $table->addColumn('priority', 'smallint', [
897
+                'notnull' => true,
898
+                'length' => 1,
899
+                'default' => 0,
900
+            ]);
901
+            $table->setPrimaryKey(['id']);
902
+            $table->addUniqueIndex(['class'], 'personal_settings_class');
903
+            $table->addIndex(['section'], 'personal_settings_section');
904
+        }
905
+
906
+        if (!$schema->hasTable('accounts')) {
907
+            $table = $schema->createTable('accounts');
908
+            $table->addColumn('uid', 'string', [
909
+                'notnull' => true,
910
+                'length' => 64,
911
+                'default' => '',
912
+            ]);
913
+            $table->addColumn('data', 'text', [
914
+                'notnull' => true,
915
+                'default' => '',
916
+            ]);
917
+            $table->setPrimaryKey(['uid']);
918
+        }
919
+        return $schema;
920
+    }
921 921
 
922 922
 }
Please login to merge, or discard this patch.
core/Command/Db/AddMissingIndices.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -41,78 +41,78 @@
 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 ($schema->hasTable('filecache')) {
104
-			$table = $schema->getTable('filecache');
105
-			if (!$table->hasIndex('fs_mtime')) {
106
-				$output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
107
-				$table->addIndex(['mtime'], 'fs_mtime');
108
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
109
-				$updated = true;
110
-				$output->writeln('<info>Filecache table updated successfully.</info>');
111
-			}
112
-		}
113
-
114
-		if (!$updated) {
115
-			$output->writeln('<info>Done.</info>');
116
-		}
117
-	}
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 ($schema->hasTable('filecache')) {
104
+            $table = $schema->getTable('filecache');
105
+            if (!$table->hasIndex('fs_mtime')) {
106
+                $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
107
+                $table->addIndex(['mtime'], 'fs_mtime');
108
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
109
+                $updated = true;
110
+                $output->writeln('<info>Filecache table updated successfully.</info>');
111
+            }
112
+        }
113
+
114
+        if (!$updated) {
115
+            $output->writeln('<info>Done.</info>');
116
+        }
117
+    }
118 118
 }
Please login to merge, or discard this patch.
core/Application.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -42,44 +42,44 @@
 block discarded – undo
42 42
  */
43 43
 class Application extends App {
44 44
 
45
-	public function __construct() {
46
-		parent::__construct('core');
45
+    public function __construct() {
46
+        parent::__construct('core');
47 47
 
48
-		$container = $this->getContainer();
48
+        $container = $this->getContainer();
49 49
 
50
-		$container->registerService('defaultMailAddress', function () {
51
-			return Util::getDefaultEmailAddress('lostpassword-noreply');
52
-		});
50
+        $container->registerService('defaultMailAddress', function () {
51
+            return Util::getDefaultEmailAddress('lostpassword-noreply');
52
+        });
53 53
 
54
-		$server = $container->getServer();
55
-		$eventDispatcher = $server->getEventDispatcher();
54
+        $server = $container->getServer();
55
+        $eventDispatcher = $server->getEventDispatcher();
56 56
 
57
-		$eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
58
-			function(GenericEvent $event) use ($container) {
59
-				/** @var MissingIndexInformation $subject */
60
-				$subject = $event->getSubject();
57
+        $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
58
+            function(GenericEvent $event) use ($container) {
59
+                /** @var MissingIndexInformation $subject */
60
+                $subject = $event->getSubject();
61 61
 
62
-				$schema = new SchemaWrapper($container->query(IDBConnection::class));
62
+                $schema = new SchemaWrapper($container->query(IDBConnection::class));
63 63
 
64
-				if ($schema->hasTable('share')) {
65
-					$table = $schema->getTable('share');
64
+                if ($schema->hasTable('share')) {
65
+                    $table = $schema->getTable('share');
66 66
 
67
-					if (!$table->hasIndex('share_with_index')) {
68
-						$subject->addHintForMissingSubject($table->getName(), 'share_with_index');
69
-					}
70
-					if (!$table->hasIndex('parent_index')) {
71
-						$subject->addHintForMissingSubject($table->getName(), 'parent_index');
72
-					}
73
-				}
67
+                    if (!$table->hasIndex('share_with_index')) {
68
+                        $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
69
+                    }
70
+                    if (!$table->hasIndex('parent_index')) {
71
+                        $subject->addHintForMissingSubject($table->getName(), 'parent_index');
72
+                    }
73
+                }
74 74
 
75
-				if ($schema->hasTable('filecache')) {
76
-					$table = $schema->getTable('filecache');
75
+                if ($schema->hasTable('filecache')) {
76
+                    $table = $schema->getTable('filecache');
77 77
 
78
-					if (!$table->hasIndex('fs_mtime')) {
79
-						$subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
80
-					}
81
-				}
82
-			}
83
-		);
84
-	}
78
+                    if (!$table->hasIndex('fs_mtime')) {
79
+                        $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
80
+                    }
81
+                }
82
+            }
83
+        );
84
+    }
85 85
 }
Please login to merge, or discard this patch.