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