Completed
Push — master ( 63676d...3faef6 )
by Lukas
28:10 queued 12:28
created

Version13000Date20170718121200::changeSchema()   F

Complexity

Conditions 30
Paths > 20000

Size

Total Lines 859
Code Lines 653

Duplication

Lines 331
Ratio 38.53 %

Importance

Changes 0
Metric Value
cc 30
eloc 653
nc 536870912
nop 3
dl 331
loc 859
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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