| Conditions | 22 |
| Paths | > 20000 |
| Total Lines | 1133 |
| Code Lines | 648 |
| Lines | 31 |
| Ratio | 2.74 % |
| 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 |
||
| 32 | public function changeSchema(Schema $schema, array $options) { |
||
| 33 | $prefix = $options['tablePrefix']; |
||
| 34 | |||
| 35 | if (!$schema->hasTable("${prefix}addressbookchanges")) { |
||
| 36 | $addressBookChangesTable = $schema->createTable("${prefix}addressbookchanges"); |
||
| 37 | |||
| 38 | $addressBookChangesTable->addColumn( |
||
| 39 | 'id', |
||
| 40 | Type::INTEGER, |
||
| 41 | [ |
||
| 42 | 'notnull' => true, |
||
| 43 | 'autoincrement' => true, |
||
| 44 | 'unsigned' => true |
||
| 45 | ] |
||
| 46 | ); |
||
| 47 | |||
| 48 | $addressBookChangesTable->addColumn( |
||
| 49 | 'uri', |
||
| 50 | Type::STRING, |
||
| 51 | [ |
||
| 52 | 'notnull' => false, |
||
| 53 | 'default' => null, |
||
| 54 | 'length' => 255 |
||
| 55 | ] |
||
| 56 | ); |
||
| 57 | |||
| 58 | $addressBookChangesTable->addColumn( |
||
| 59 | 'synctoken', |
||
| 60 | Type::INTEGER, |
||
| 61 | [ |
||
| 62 | 'notnull' => true, |
||
| 63 | 'default' => 1, |
||
| 64 | 'unsigned' => true |
||
| 65 | ] |
||
| 66 | ); |
||
| 67 | |||
| 68 | $addressBookChangesTable->addColumn( |
||
| 69 | 'addressbookid', |
||
| 70 | Type::INTEGER, |
||
| 71 | [ |
||
| 72 | 'notnull' => true |
||
| 73 | ] |
||
| 74 | ); |
||
| 75 | |||
| 76 | $addressBookChangesTable->addColumn( |
||
| 77 | 'operation', |
||
| 78 | Type::SMALLINT, |
||
| 79 | [ |
||
| 80 | 'notnull' => true |
||
| 81 | ] |
||
| 82 | ); |
||
| 83 | $addressBookChangesTable->setPrimaryKey(['id']); |
||
| 84 | $addressBookChangesTable->addIndex(['addressbookid', 'synctoken'], 'addressbookid_synctoken'); |
||
| 85 | } |
||
| 86 | |||
| 87 | if (!$schema->hasTable("${prefix}addressbooks")) { |
||
| 88 | $addressBooksTable = $schema->createTable("${prefix}addressbooks"); |
||
| 89 | |||
| 90 | $addressBooksTable->addColumn( |
||
| 91 | 'id', |
||
| 92 | Type::INTEGER, |
||
| 93 | [ |
||
| 94 | 'unsigned' => true, |
||
| 95 | 'autoincrement' => true, |
||
| 96 | 'notnull' => true |
||
| 97 | ] |
||
| 98 | ); |
||
| 99 | |||
| 100 | $addressBooksTable->addColumn( |
||
| 101 | 'principaluri', |
||
| 102 | Type::STRING, |
||
| 103 | [ |
||
| 104 | 'default' => null, |
||
| 105 | 'notnull' => false, |
||
| 106 | 'length' => 255 |
||
| 107 | ] |
||
| 108 | ); |
||
| 109 | |||
| 110 | $addressBooksTable->addColumn( |
||
| 111 | 'displayname', |
||
| 112 | Type::STRING, |
||
| 113 | [ |
||
| 114 | 'default' => null, |
||
| 115 | 'notnull' => false, |
||
| 116 | 'length' => 255 |
||
| 117 | ] |
||
| 118 | ); |
||
| 119 | |||
| 120 | $addressBooksTable->addColumn( |
||
| 121 | 'uri', |
||
| 122 | Type::STRING, |
||
| 123 | [ |
||
| 124 | 'default' => null, |
||
| 125 | 'notnull' => false, |
||
| 126 | 'length' => 255 |
||
| 127 | ] |
||
| 128 | ); |
||
| 129 | |||
| 130 | $addressBooksTable->addColumn( |
||
| 131 | 'description', |
||
| 132 | Type::STRING, |
||
| 133 | [ |
||
| 134 | 'default' => null, |
||
| 135 | 'length' => 255, |
||
| 136 | 'notnull' => false |
||
| 137 | ] |
||
| 138 | ); |
||
| 139 | |||
| 140 | $addressBooksTable->addColumn( |
||
| 141 | 'synctoken', |
||
| 142 | Type::INTEGER, |
||
| 143 | [ |
||
| 144 | 'default' => 1, |
||
| 145 | 'unsigned' => true |
||
| 146 | ] |
||
| 147 | ); |
||
| 148 | |||
| 149 | $addressBooksTable->setPrimaryKey(['id']); |
||
| 150 | $addressBooksTable->addUniqueIndex(['principaluri', 'uri'], 'addressbook_index'); |
||
| 151 | } |
||
| 152 | |||
| 153 | if (!$schema->hasTable("${prefix}calendarchanges")) { |
||
| 154 | $calendarChangesTable = $schema->createTable("${prefix}calendarchanges"); |
||
| 155 | |||
| 156 | $calendarChangesTable->addColumn( |
||
| 157 | 'id', |
||
| 158 | Type::INTEGER, |
||
| 159 | [ |
||
| 160 | 'unsigned' => true, |
||
| 161 | 'autoincrement' => true, |
||
| 162 | 'notnull' => true |
||
| 163 | ] |
||
| 164 | ); |
||
| 165 | |||
| 166 | $calendarChangesTable->addColumn( |
||
| 167 | 'uri', |
||
| 168 | Type::STRING, |
||
| 169 | [ |
||
| 170 | 'default' => null, |
||
| 171 | 'length' => 255, |
||
| 172 | 'notnull' => false |
||
| 173 | ] |
||
| 174 | ); |
||
| 175 | |||
| 176 | $calendarChangesTable->addColumn( |
||
| 177 | 'synctoken', |
||
| 178 | Type::INTEGER, |
||
| 179 | [ |
||
| 180 | 'default' => 1, |
||
| 181 | 'unsigned' => true |
||
| 182 | ] |
||
| 183 | ); |
||
| 184 | |||
| 185 | $calendarChangesTable->addColumn( |
||
| 186 | 'calendarid', |
||
| 187 | Type::INTEGER |
||
| 188 | ); |
||
| 189 | |||
| 190 | $calendarChangesTable->addColumn( |
||
| 191 | 'operation', |
||
| 192 | Type::SMALLINT |
||
| 193 | ); |
||
| 194 | |||
| 195 | $calendarChangesTable->setPrimaryKey(['id']); |
||
| 196 | $calendarChangesTable->addIndex(['calendarid', 'synctoken'], 'calendarid_synctoken'); |
||
| 197 | } |
||
| 198 | |||
| 199 | if (!$schema->hasTable("${prefix}calendarobjects")) { |
||
| 200 | $calendarObjectsTable = $schema->createTable("${prefix}calendarobjects"); |
||
| 201 | |||
| 202 | $calendarObjectsTable->addColumn( |
||
| 203 | 'id', |
||
| 204 | Type::INTEGER, |
||
| 205 | [ |
||
| 206 | 'unsigned' => true, |
||
| 207 | 'autoincrement' => true, |
||
| 208 | 'notnull' => true |
||
| 209 | ] |
||
| 210 | ); |
||
| 211 | |||
| 212 | $calendarObjectsTable->addColumn( |
||
| 213 | 'calendardata', |
||
| 214 | Type::BLOB, |
||
| 215 | [ |
||
| 216 | 'default' => null, |
||
| 217 | 'notnull' => false |
||
| 218 | ] |
||
| 219 | ); |
||
| 220 | |||
| 221 | $calendarObjectsTable->addColumn( |
||
| 222 | 'uri', |
||
| 223 | Type::STRING, |
||
| 224 | [ |
||
| 225 | 'default' => null, |
||
| 226 | 'length' => 255, |
||
| 227 | 'notnull' => false |
||
| 228 | ] |
||
| 229 | ); |
||
| 230 | |||
| 231 | $calendarObjectsTable->addColumn( |
||
| 232 | 'calendarid', |
||
| 233 | Type::INTEGER, |
||
| 234 | [ |
||
| 235 | 'unsigned' => true |
||
| 236 | ] |
||
| 237 | ); |
||
| 238 | |||
| 239 | $calendarObjectsTable->addColumn( |
||
| 240 | 'lastmodified', |
||
| 241 | Type::INTEGER, |
||
| 242 | [ |
||
| 243 | 'default' => null, |
||
| 244 | 'unsigned' => true, |
||
| 245 | 'notnull' => false |
||
| 246 | ] |
||
| 247 | ); |
||
| 248 | |||
| 249 | $calendarObjectsTable->addColumn( |
||
| 250 | 'etag', |
||
| 251 | Type::STRING, |
||
| 252 | [ |
||
| 253 | 'default' => null, |
||
| 254 | 'length' => 32, |
||
| 255 | 'notnull' => false |
||
| 256 | ] |
||
| 257 | ); |
||
| 258 | |||
| 259 | $calendarObjectsTable->addColumn( |
||
| 260 | 'size', |
||
| 261 | Type::BIGINT, |
||
| 262 | [ |
||
| 263 | 'unsigned' => true |
||
| 264 | ] |
||
| 265 | ); |
||
| 266 | |||
| 267 | $calendarObjectsTable->addColumn( |
||
| 268 | 'componenttype', |
||
| 269 | Type::STRING, |
||
| 270 | [ |
||
| 271 | 'default' => null, |
||
| 272 | 'length' => 255, |
||
| 273 | 'notnull' => false |
||
| 274 | ] |
||
| 275 | ); |
||
| 276 | |||
| 277 | $calendarObjectsTable->addColumn( |
||
| 278 | 'firstoccurence', |
||
| 279 | Type::INTEGER, |
||
| 280 | [ |
||
| 281 | 'default' => null, |
||
| 282 | 'unsigned' => true, |
||
| 283 | 'notnull' => false |
||
| 284 | ] |
||
| 285 | ); |
||
| 286 | |||
| 287 | $calendarObjectsTable->addColumn( |
||
| 288 | 'lastoccurence', |
||
| 289 | Type::INTEGER, |
||
| 290 | [ |
||
| 291 | 'default' => null, |
||
| 292 | 'unsigned' => true, |
||
| 293 | 'notnull' => false |
||
| 294 | ] |
||
| 295 | ); |
||
| 296 | |||
| 297 | $calendarObjectsTable->addColumn( |
||
| 298 | 'uid', |
||
| 299 | Type::STRING, |
||
| 300 | [ |
||
| 301 | 'default' => null, |
||
| 302 | 'length' => 255, |
||
| 303 | 'notnull' => false |
||
| 304 | ] |
||
| 305 | ); |
||
| 306 | |||
| 307 | $calendarObjectsTable->setPrimaryKey(['id']); |
||
| 308 | $calendarObjectsTable->addUniqueIndex(['calendarid', 'uri'], 'calobjects_index'); |
||
| 309 | } |
||
| 310 | |||
| 311 | if (!$schema->hasTable("${prefix}calendars")) { |
||
| 312 | $calendarsTable = $schema->createTable("${prefix}calendars"); |
||
| 313 | |||
| 314 | $calendarsTable->addColumn( |
||
| 315 | 'id', |
||
| 316 | Type::INTEGER, |
||
| 317 | [ |
||
| 318 | 'unsigned' => true, |
||
| 319 | 'autoincrement' => true, |
||
| 320 | 'notnull' => true |
||
| 321 | ] |
||
| 322 | ); |
||
| 323 | |||
| 324 | $calendarsTable->addColumn( |
||
| 325 | 'principaluri', |
||
| 326 | Type::STRING, |
||
| 327 | [ |
||
| 328 | 'default' => null, |
||
| 329 | 'length' => 255, |
||
| 330 | 'notnull' => false |
||
| 331 | ] |
||
| 332 | ); |
||
| 333 | |||
| 334 | $calendarsTable->addColumn( |
||
| 335 | 'displayname', |
||
| 336 | Type::STRING, |
||
| 337 | [ |
||
| 338 | 'default' => null, |
||
| 339 | 'length' => 255, |
||
| 340 | 'notnull' => false |
||
| 341 | ] |
||
| 342 | ); |
||
| 343 | |||
| 344 | $calendarsTable->addColumn( |
||
| 345 | 'uri', |
||
| 346 | Type::STRING, |
||
| 347 | [ |
||
| 348 | 'default' => null, |
||
| 349 | 'length' => 255, |
||
| 350 | 'notnull' => false |
||
| 351 | ] |
||
| 352 | ); |
||
| 353 | |||
| 354 | $calendarsTable->addColumn( |
||
| 355 | 'synctoken', |
||
| 356 | Type::INTEGER, |
||
| 357 | [ |
||
| 358 | 'default' => 1, |
||
| 359 | 'unsigned' => true |
||
| 360 | ] |
||
| 361 | ); |
||
| 362 | |||
| 363 | $calendarsTable->addColumn( |
||
| 364 | 'description', |
||
| 365 | Type::STRING, |
||
| 366 | [ |
||
| 367 | 'default' => null, |
||
| 368 | 'length' => 255, |
||
| 369 | 'notnull' => false |
||
| 370 | ] |
||
| 371 | ); |
||
| 372 | |||
| 373 | $calendarsTable->addColumn( |
||
| 374 | 'calendarorder', |
||
| 375 | Type::INTEGER, |
||
| 376 | [ |
||
| 377 | 'default' => 0, |
||
| 378 | 'unsigned' => true |
||
| 379 | ] |
||
| 380 | ); |
||
| 381 | |||
| 382 | $calendarsTable->addColumn( |
||
| 383 | 'calendarcolor', |
||
| 384 | Type::STRING, |
||
| 385 | [ |
||
| 386 | 'default' => null, |
||
| 387 | 'length' => 255, |
||
| 388 | 'notnull' => false |
||
| 389 | ] |
||
| 390 | ); |
||
| 391 | |||
| 392 | $calendarsTable->addColumn( |
||
| 393 | 'timezone', |
||
| 394 | Type::TEXT, |
||
| 395 | [ |
||
| 396 | 'default' => null, |
||
| 397 | 'notnull' => false |
||
| 398 | ] |
||
| 399 | ); |
||
| 400 | |||
| 401 | $calendarsTable->addColumn( |
||
| 402 | 'components', |
||
| 403 | Type::STRING, |
||
| 404 | [ |
||
| 405 | 'default' => null, |
||
| 406 | 'length' => 255, |
||
| 407 | 'notnull' => false |
||
| 408 | ] |
||
| 409 | ); |
||
| 410 | |||
| 411 | $calendarsTable->addColumn( |
||
| 412 | 'transparent', |
||
| 413 | Type::SMALLINT, |
||
| 414 | [ |
||
| 415 | 'default' => 0, |
||
| 416 | ] |
||
| 417 | ); |
||
| 418 | |||
| 419 | $calendarsTable->setPrimaryKey(['id']); |
||
| 420 | $calendarsTable->addUniqueIndex(['principaluri', 'uri'], 'calendars_index'); |
||
| 421 | } |
||
| 422 | |||
| 423 | if (!$schema->hasTable("${prefix}calendarsubscriptions")) { |
||
| 424 | $calendarSubscriptionsTable = $schema->createTable("${prefix}calendarsubscriptions"); |
||
| 425 | |||
| 426 | $calendarSubscriptionsTable->addColumn( |
||
| 427 | 'id', |
||
| 428 | Type::INTEGER, |
||
| 429 | [ |
||
| 430 | 'unsigned' => true, |
||
| 431 | 'autoincrement' => true, |
||
| 432 | 'notnull' => true |
||
| 433 | ] |
||
| 434 | ); |
||
| 435 | |||
| 436 | $calendarSubscriptionsTable->addColumn( |
||
| 437 | 'uri', |
||
| 438 | Type::STRING, |
||
| 439 | [ |
||
| 440 | 'default' => null, |
||
| 441 | 'length' => 255, |
||
| 442 | 'notnull' => false |
||
| 443 | ] |
||
| 444 | ); |
||
| 445 | |||
| 446 | $calendarSubscriptionsTable->addColumn( |
||
| 447 | 'principaluri', |
||
| 448 | Type::STRING, |
||
| 449 | [ |
||
| 450 | 'default' => null, |
||
| 451 | 'length' => 255, |
||
| 452 | 'notnull' => false |
||
| 453 | ] |
||
| 454 | ); |
||
| 455 | |||
| 456 | $calendarSubscriptionsTable->addColumn( |
||
| 457 | 'source', |
||
| 458 | Type::STRING, |
||
| 459 | [ |
||
| 460 | 'default' => null, |
||
| 461 | 'length' => 255, |
||
| 462 | 'notnull' => false |
||
| 463 | ] |
||
| 464 | ); |
||
| 465 | |||
| 466 | $calendarSubscriptionsTable->addColumn( |
||
| 467 | 'displayname', |
||
| 468 | Type::STRING, |
||
| 469 | [ |
||
| 470 | 'default' => null, |
||
| 471 | 'length' => 100, |
||
| 472 | 'notnull' => false |
||
| 473 | ] |
||
| 474 | ); |
||
| 475 | |||
| 476 | $calendarSubscriptionsTable->addColumn( |
||
| 477 | 'refreshrate', |
||
| 478 | Type::STRING, |
||
| 479 | [ |
||
| 480 | 'default' => null, |
||
| 481 | 'length' => 10, |
||
| 482 | 'notnull' => false |
||
| 483 | ] |
||
| 484 | ); |
||
| 485 | |||
| 486 | $calendarSubscriptionsTable->addColumn( |
||
| 487 | 'calendarorder', |
||
| 488 | Type::INTEGER, |
||
| 489 | [ |
||
| 490 | 'default' => 0, |
||
| 491 | 'unsigned' => true |
||
| 492 | ] |
||
| 493 | ); |
||
| 494 | |||
| 495 | $calendarSubscriptionsTable->addColumn( |
||
| 496 | 'calendarcolor', |
||
| 497 | Type::STRING, |
||
| 498 | [ |
||
| 499 | 'default' => null, |
||
| 500 | 'length' => 255, |
||
| 501 | 'notnull' => false |
||
| 502 | ] |
||
| 503 | ); |
||
| 504 | |||
| 505 | $calendarSubscriptionsTable->addColumn( |
||
| 506 | 'striptodos', |
||
| 507 | Type::SMALLINT, |
||
| 508 | [ |
||
| 509 | 'default' => null, |
||
| 510 | 'notnull' => false |
||
| 511 | ] |
||
| 512 | ); |
||
| 513 | |||
| 514 | $calendarSubscriptionsTable->addColumn( |
||
| 515 | 'stripalarms', |
||
| 516 | Type::SMALLINT, |
||
| 517 | [ |
||
| 518 | 'default' => null, |
||
| 519 | 'notnull' => false |
||
| 520 | ] |
||
| 521 | ); |
||
| 522 | |||
| 523 | $calendarSubscriptionsTable->addColumn( |
||
| 524 | 'stripattachments', |
||
| 525 | Type::SMALLINT, |
||
| 526 | [ |
||
| 527 | 'default' => null, |
||
| 528 | 'notnull' => false |
||
| 529 | ] |
||
| 530 | ); |
||
| 531 | |||
| 532 | $calendarSubscriptionsTable->addColumn( |
||
| 533 | 'lastmodified', |
||
| 534 | Type::INTEGER, |
||
| 535 | [ |
||
| 536 | 'default' => null, |
||
| 537 | 'unsigned' => true, |
||
| 538 | 'notnull' => false |
||
| 539 | ] |
||
| 540 | ); |
||
| 541 | |||
| 542 | $calendarSubscriptionsTable->setPrimaryKey(['id']); |
||
| 543 | $calendarSubscriptionsTable->addUniqueIndex(['principaluri', 'uri'], 'calsub_index'); |
||
| 544 | } |
||
| 545 | |||
| 546 | if (!$schema->hasTable("${prefix}cards")) { |
||
| 547 | $cardsTable = $schema->createTable("${prefix}cards"); |
||
| 548 | |||
| 549 | $cardsTable->addColumn( |
||
| 550 | 'id', |
||
| 551 | Type::INTEGER, |
||
| 552 | [ |
||
| 553 | 'unsigned' => true, |
||
| 554 | 'autoincrement' => true, |
||
| 555 | 'notnull' => true |
||
| 556 | ] |
||
| 557 | ); |
||
| 558 | |||
| 559 | $cardsTable->addColumn( |
||
| 560 | 'addressbookid', |
||
| 561 | Type::INTEGER, |
||
| 562 | [ |
||
| 563 | 'default' => 0 |
||
| 564 | ] |
||
| 565 | ); |
||
| 566 | |||
| 567 | $cardsTable->addColumn( |
||
| 568 | 'carddata', |
||
| 569 | Type::BLOB, |
||
| 570 | [ |
||
| 571 | 'default' => null, |
||
| 572 | 'notnull' => false |
||
| 573 | ] |
||
| 574 | ); |
||
| 575 | |||
| 576 | $cardsTable->addColumn( |
||
| 577 | 'uri', |
||
| 578 | Type::STRING, |
||
| 579 | [ |
||
| 580 | 'default' => null, |
||
| 581 | 'length' => 255, |
||
| 582 | 'notnull' => false |
||
| 583 | ] |
||
| 584 | ); |
||
| 585 | |||
| 586 | $cardsTable->addColumn( |
||
| 587 | 'lastmodified', |
||
| 588 | Type::BIGINT, |
||
| 589 | [ |
||
| 590 | 'default' => null, |
||
| 591 | 'unsigned' => true, |
||
| 592 | 'notnull' => false |
||
| 593 | ] |
||
| 594 | ); |
||
| 595 | |||
| 596 | $cardsTable->addColumn( |
||
| 597 | 'etag', |
||
| 598 | Type::STRING, |
||
| 599 | [ |
||
| 600 | 'default' => null, |
||
| 601 | 'length' => 32, |
||
| 602 | 'notnull' => false |
||
| 603 | ] |
||
| 604 | ); |
||
| 605 | |||
| 606 | $cardsTable->addColumn( |
||
| 607 | 'size', |
||
| 608 | Type::BIGINT, |
||
| 609 | [ |
||
| 610 | 'unsigned' => true |
||
| 611 | ] |
||
| 612 | ); |
||
| 613 | |||
| 614 | $cardsTable->setPrimaryKey(['id']); |
||
| 615 | } |
||
| 616 | |||
| 617 | if (!$schema->hasTable("${prefix}cards_properties")) { |
||
| 618 | $cardsPropertiesTable = $schema->createTable("${prefix}cards_properties"); |
||
| 619 | |||
| 620 | $cardsPropertiesTable->addColumn( |
||
| 621 | 'id', |
||
| 622 | Type::INTEGER, |
||
| 623 | [ |
||
| 624 | 'unsigned' => true, |
||
| 625 | 'autoincrement' => true, |
||
| 626 | 'notnull' => true |
||
| 627 | ] |
||
| 628 | ); |
||
| 629 | |||
| 630 | $cardsPropertiesTable->addColumn( |
||
| 631 | 'addressbookid', |
||
| 632 | Type::BIGINT, |
||
| 633 | [ |
||
| 634 | 'default' => 0 |
||
| 635 | ] |
||
| 636 | ); |
||
| 637 | |||
| 638 | $cardsPropertiesTable->addColumn( |
||
| 639 | 'cardid', |
||
| 640 | Type::BIGINT, |
||
| 641 | [ |
||
| 642 | 'default' => 0, |
||
| 643 | 'unsigned' => true |
||
| 644 | ] |
||
| 645 | ); |
||
| 646 | |||
| 647 | $cardsPropertiesTable->addColumn( |
||
| 648 | 'name', |
||
| 649 | Type::STRING, |
||
| 650 | [ |
||
| 651 | 'default' => null, |
||
| 652 | 'length' => 64, |
||
| 653 | 'notnull' => false |
||
| 654 | ] |
||
| 655 | ); |
||
| 656 | |||
| 657 | $cardsPropertiesTable->addColumn( |
||
| 658 | 'value', |
||
| 659 | Type::STRING, |
||
| 660 | [ |
||
| 661 | 'default' => null, |
||
| 662 | 'length' => 255, |
||
| 663 | 'notnull' => false |
||
| 664 | ] |
||
| 665 | ); |
||
| 666 | |||
| 667 | $cardsPropertiesTable->addColumn( |
||
| 668 | 'preferred', |
||
| 669 | Type::INTEGER, |
||
| 670 | [ |
||
| 671 | 'default' => 1 |
||
| 672 | ] |
||
| 673 | ); |
||
| 674 | |||
| 675 | $cardsPropertiesTable->setPrimaryKey(['id']); |
||
| 676 | $cardsPropertiesTable->addIndex(['value'], 'card_value_index'); |
||
| 677 | $cardsPropertiesTable->addIndex(['name'], 'card_name_index'); |
||
| 678 | $cardsPropertiesTable->addIndex(['cardid'], 'card_contactid_index'); |
||
| 679 | } |
||
| 680 | |||
| 681 | |||
| 682 | if (!$schema->hasTable("${prefix}comments")) { |
||
| 683 | $commentsTable = $schema->createTable("${prefix}comments"); |
||
| 684 | |||
| 685 | $commentsTable->addColumn( |
||
| 686 | 'id', |
||
| 687 | Type::INTEGER, |
||
| 688 | [ |
||
| 689 | 'unsigned' => true, |
||
| 690 | 'autoincrement' => true, |
||
| 691 | 'notnull' => true |
||
| 692 | ] |
||
| 693 | ); |
||
| 694 | |||
| 695 | $commentsTable->addColumn( |
||
| 696 | 'parent_id', |
||
| 697 | Type::INTEGER, |
||
| 698 | [ |
||
| 699 | 'default' => 0, |
||
| 700 | 'unsigned' => true |
||
| 701 | ] |
||
| 702 | ); |
||
| 703 | |||
| 704 | $commentsTable->addColumn( |
||
| 705 | 'topmost_parent_id', |
||
| 706 | Type::INTEGER, |
||
| 707 | [ |
||
| 708 | 'default' => 0, |
||
| 709 | 'unsigned' => true |
||
| 710 | ] |
||
| 711 | ); |
||
| 712 | |||
| 713 | $commentsTable->addColumn( |
||
| 714 | 'children_count', |
||
| 715 | Type::INTEGER, |
||
| 716 | [ |
||
| 717 | 'default' => 0, |
||
| 718 | 'unsigned' => true |
||
| 719 | ] |
||
| 720 | ); |
||
| 721 | |||
| 722 | $commentsTable->addColumn( |
||
| 723 | 'actor_type', |
||
| 724 | Type::STRING, |
||
| 725 | [ |
||
| 726 | 'default' => '', |
||
| 727 | 'length' => 64 |
||
| 728 | ] |
||
| 729 | ); |
||
| 730 | |||
| 731 | $commentsTable->addColumn( |
||
| 732 | 'actor_id', |
||
| 733 | Type::STRING, |
||
| 734 | [ |
||
| 735 | 'default' => '', |
||
| 736 | 'length' => 64 |
||
| 737 | ] |
||
| 738 | ); |
||
| 739 | |||
| 740 | $commentsTable->addColumn( |
||
| 741 | 'message', |
||
| 742 | Type::TEXT, |
||
| 743 | [ |
||
| 744 | 'default' => null, |
||
| 745 | 'notnull' => false |
||
| 746 | ] |
||
| 747 | ); |
||
| 748 | |||
| 749 | $commentsTable->addColumn( |
||
| 750 | 'verb', |
||
| 751 | Type::STRING, |
||
| 752 | [ |
||
| 753 | 'default' => null, |
||
| 754 | 'length' => 64, |
||
| 755 | 'notnull' => false |
||
| 756 | ] |
||
| 757 | ); |
||
| 758 | |||
| 759 | $commentsTable->addColumn( |
||
| 760 | 'creation_timestamp', |
||
| 761 | Type::DATETIME, |
||
| 762 | [ |
||
| 763 | 'default' => null, |
||
| 764 | 'notnull' => false |
||
| 765 | ] |
||
| 766 | ); |
||
| 767 | |||
| 768 | $commentsTable->addColumn( |
||
| 769 | 'latest_child_timestamp', |
||
| 770 | Type::DATETIME, |
||
| 771 | [ |
||
| 772 | 'default' => null, |
||
| 773 | 'notnull' => false |
||
| 774 | ] |
||
| 775 | ); |
||
| 776 | |||
| 777 | $commentsTable->addColumn( |
||
| 778 | 'object_type', |
||
| 779 | Type::STRING, |
||
| 780 | [ |
||
| 781 | 'default' => '', |
||
| 782 | 'length' => 64 |
||
| 783 | ] |
||
| 784 | ); |
||
| 785 | |||
| 786 | $commentsTable->addColumn( |
||
| 787 | 'object_id', |
||
| 788 | Type::STRING, |
||
| 789 | [ |
||
| 790 | 'default' => '', |
||
| 791 | 'length' => 64 |
||
| 792 | ] |
||
| 793 | ); |
||
| 794 | |||
| 795 | $commentsTable->setPrimaryKey(['id']); |
||
| 796 | $commentsTable->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
||
| 797 | $commentsTable->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
||
| 798 | $commentsTable->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
||
| 799 | $commentsTable->addIndex(['parent_id'], 'comments_parent_id_index'); |
||
| 800 | } |
||
| 801 | |||
| 802 | |||
| 803 | if (!$schema->hasTable("${prefix}comments_read_markers")) { |
||
| 804 | $commentsReadMarkersTable = $schema->createTable("${prefix}comments_read_markers"); |
||
| 805 | |||
| 806 | $commentsReadMarkersTable->addColumn( |
||
| 807 | 'user_id', |
||
| 808 | Type::STRING, |
||
| 809 | [ |
||
| 810 | 'default' => '', |
||
| 811 | 'length' => 64 |
||
| 812 | ] |
||
| 813 | ); |
||
| 814 | |||
| 815 | $commentsReadMarkersTable->addColumn( |
||
| 816 | 'marker_datetime', |
||
| 817 | Type::DATETIME, |
||
| 818 | [ |
||
| 819 | 'default' => null, |
||
| 820 | 'notnull' => false |
||
| 821 | ] |
||
| 822 | ); |
||
| 823 | |||
| 824 | $commentsReadMarkersTable->addColumn( |
||
| 825 | 'object_type', |
||
| 826 | Type::STRING, |
||
| 827 | [ |
||
| 828 | 'default' => '', |
||
| 829 | 'length' => 64 |
||
| 830 | ] |
||
| 831 | ); |
||
| 832 | |||
| 833 | $commentsReadMarkersTable->addColumn( |
||
| 834 | 'object_id', |
||
| 835 | Type::STRING, |
||
| 836 | [ |
||
| 837 | 'default' => '', |
||
| 838 | 'length' => 64 |
||
| 839 | ] |
||
| 840 | ); |
||
| 841 | |||
| 842 | $commentsReadMarkersTable->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
||
| 843 | $commentsReadMarkersTable->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
||
| 844 | } |
||
| 845 | |||
| 846 | if (!$schema->hasTable("${prefix}credentials")) { |
||
| 847 | $credentialsTable = $schema->createTable("${prefix}credentials"); |
||
| 848 | |||
| 849 | $credentialsTable->addColumn( |
||
| 850 | 'user', |
||
| 851 | Type::STRING, |
||
| 852 | [ |
||
| 853 | 'length' => 64 |
||
| 854 | ] |
||
| 855 | ); |
||
| 856 | |||
| 857 | $credentialsTable->addColumn( |
||
| 858 | 'identifier', |
||
| 859 | Type::STRING, |
||
| 860 | [ |
||
| 861 | 'length' => 64 |
||
| 862 | ] |
||
| 863 | ); |
||
| 864 | |||
| 865 | $credentialsTable->addColumn( |
||
| 866 | 'credentials', |
||
| 867 | Type::TEXT, |
||
| 868 | [ |
||
| 869 | 'default' => null, |
||
| 870 | 'notnull' => false |
||
| 871 | ] |
||
| 872 | ); |
||
| 873 | |||
| 874 | $credentialsTable->setPrimaryKey(['user', 'identifier']); |
||
| 875 | $credentialsTable->addIndex(['user'], 'credentials_user'); |
||
| 876 | } |
||
| 877 | |||
| 878 | if (!$schema->hasTable("${prefix}dav_shares")) { |
||
| 879 | $davSharesTable = $schema->createTable("${prefix}dav_shares"); |
||
| 880 | |||
| 881 | $davSharesTable->addColumn( |
||
| 882 | 'id', |
||
| 883 | Type::INTEGER, |
||
| 884 | [ |
||
| 885 | 'autoincrement' => true, |
||
| 886 | 'unsigned' => true, |
||
| 887 | 'notnull' => true |
||
| 888 | ] |
||
| 889 | ); |
||
| 890 | |||
| 891 | $davSharesTable->addColumn( |
||
| 892 | 'principaluri', |
||
| 893 | Type::STRING, |
||
| 894 | [ |
||
| 895 | 'default' => null, |
||
| 896 | 'length' => 255, |
||
| 897 | 'notnull' => false |
||
| 898 | ] |
||
| 899 | ); |
||
| 900 | |||
| 901 | $davSharesTable->addColumn( |
||
| 902 | 'type', |
||
| 903 | Type::STRING, |
||
| 904 | [ |
||
| 905 | 'default' => null, |
||
| 906 | 'length' => 255, |
||
| 907 | 'notnull' => false |
||
| 908 | ] |
||
| 909 | ); |
||
| 910 | |||
| 911 | $davSharesTable->addColumn( |
||
| 912 | 'access', |
||
| 913 | Type::SMALLINT, |
||
| 914 | [ |
||
| 915 | 'default' => null, |
||
| 916 | 'notnull' => false |
||
| 917 | ] |
||
| 918 | ); |
||
| 919 | |||
| 920 | $davSharesTable->addColumn( |
||
| 921 | 'resourceid', |
||
| 922 | Type::INTEGER, |
||
| 923 | [ |
||
| 924 | 'unsigned' => true |
||
| 925 | ] |
||
| 926 | ); |
||
| 927 | |||
| 928 | $davSharesTable->setPrimaryKey(['id']); |
||
| 929 | $davSharesTable->addUniqueIndex(['principaluri', 'resourceid', 'type'], 'dav_shares_index'); |
||
| 930 | } |
||
| 931 | |||
| 932 | if (!$schema->hasTable("${prefix}mounts")) { |
||
| 933 | $mountsTable = $schema->createTable("${prefix}mounts"); |
||
| 934 | |||
| 935 | $mountsTable->addColumn( |
||
| 936 | 'id', |
||
| 937 | Type::INTEGER, |
||
| 938 | [ |
||
| 939 | 'autoincrement' => true, |
||
| 940 | 'notnull' => true |
||
| 941 | ] |
||
| 942 | ); |
||
| 943 | |||
| 944 | $mountsTable->addColumn( |
||
| 945 | 'storage_id', |
||
| 946 | Type::INTEGER |
||
| 947 | ); |
||
| 948 | |||
| 949 | $mountsTable->addColumn( |
||
| 950 | 'root_id', |
||
| 951 | Type::INTEGER |
||
| 952 | ); |
||
| 953 | |||
| 954 | $mountsTable->addColumn( |
||
| 955 | 'user_id', |
||
| 956 | Type::STRING, |
||
| 957 | [ |
||
| 958 | 'length' => 64 |
||
| 959 | ] |
||
| 960 | ); |
||
| 961 | |||
| 962 | $mountsTable->addColumn( |
||
| 963 | 'mount_point', |
||
| 964 | Type::STRING, |
||
| 965 | [ |
||
| 966 | 'length' => 4000 |
||
| 967 | ] |
||
| 968 | ); |
||
| 969 | |||
| 970 | $mountsTable->setPrimaryKey(['id']); |
||
| 971 | $mountsTable->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
||
| 972 | $mountsTable->addIndex(['root_id'], 'mounts_root_index'); |
||
| 973 | $mountsTable->addIndex(['storage_id'], 'mounts_storage_index'); |
||
| 974 | $mountsTable->addIndex(['user_id'], 'mounts_user_index'); |
||
| 975 | } |
||
| 976 | |||
| 977 | if (!$schema->hasTable("${prefix}schedulingobjects")) { |
||
| 978 | $schedulingObjectsTable = $schema->createTable("${prefix}schedulingobjects"); |
||
| 979 | |||
| 980 | $schedulingObjectsTable->addColumn( |
||
| 981 | 'id', |
||
| 982 | Type::INTEGER, |
||
| 983 | [ |
||
| 984 | 'unsigned' => true, |
||
| 985 | 'autoincrement' => true, |
||
| 986 | 'notnull' => true |
||
| 987 | ] |
||
| 988 | ); |
||
| 989 | |||
| 990 | $schedulingObjectsTable->addColumn( |
||
| 991 | 'principaluri', |
||
| 992 | Type::STRING, |
||
| 993 | [ |
||
| 994 | 'default' => null, |
||
| 995 | 'length' => 255, |
||
| 996 | 'notnull' => false |
||
| 997 | ] |
||
| 998 | ); |
||
| 999 | |||
| 1000 | $schedulingObjectsTable->addColumn( |
||
| 1001 | 'calendardata', |
||
| 1002 | Type::BLOB, |
||
| 1003 | [ |
||
| 1004 | 'default' => null, |
||
| 1005 | 'notnull' => false |
||
| 1006 | ] |
||
| 1007 | ); |
||
| 1008 | |||
| 1009 | $schedulingObjectsTable->addColumn( |
||
| 1010 | 'uri', |
||
| 1011 | Type::STRING, |
||
| 1012 | [ |
||
| 1013 | 'default' => null, |
||
| 1014 | 'length' => 255, |
||
| 1015 | 'notnull' => false |
||
| 1016 | ] |
||
| 1017 | ); |
||
| 1018 | |||
| 1019 | $schedulingObjectsTable->addColumn( |
||
| 1020 | 'lastmodified', |
||
| 1021 | Type::INTEGER, |
||
| 1022 | [ |
||
| 1023 | 'default' => null, |
||
| 1024 | 'unsigned' => true, |
||
| 1025 | 'notnull' => false |
||
| 1026 | ] |
||
| 1027 | ); |
||
| 1028 | |||
| 1029 | $schedulingObjectsTable->addColumn( |
||
| 1030 | 'etag', |
||
| 1031 | Type::STRING, |
||
| 1032 | [ |
||
| 1033 | 'default' => null, |
||
| 1034 | 'length' => 32, |
||
| 1035 | 'notnull' => false |
||
| 1036 | ] |
||
| 1037 | ); |
||
| 1038 | |||
| 1039 | $schedulingObjectsTable->addColumn( |
||
| 1040 | 'size', |
||
| 1041 | Type::BIGINT, |
||
| 1042 | [ |
||
| 1043 | 'unsigned' => true |
||
| 1044 | ] |
||
| 1045 | ); |
||
| 1046 | |||
| 1047 | $schedulingObjectsTable->setPrimaryKey(['id']); |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | if (!$schema->hasTable("${prefix}systemtag")) { |
||
| 1051 | $systemTagTable = $schema->createTable("${prefix}systemtag"); |
||
| 1052 | |||
| 1053 | $systemTagTable->addColumn( |
||
| 1054 | 'id', |
||
| 1055 | Type::INTEGER, |
||
| 1056 | [ |
||
| 1057 | 'unsigned' => true, |
||
| 1058 | 'autoincrement' => true, |
||
| 1059 | 'notnull' => true |
||
| 1060 | ] |
||
| 1061 | ); |
||
| 1062 | |||
| 1063 | $systemTagTable->addColumn( |
||
| 1064 | 'name', |
||
| 1065 | Type::STRING, |
||
| 1066 | [ |
||
| 1067 | 'default' => '', |
||
| 1068 | 'length' => 64 |
||
| 1069 | ] |
||
| 1070 | ); |
||
| 1071 | |||
| 1072 | $systemTagTable->addColumn( |
||
| 1073 | 'visibility', |
||
| 1074 | Type::SMALLINT, |
||
| 1075 | [ |
||
| 1076 | 'default' => 1 |
||
| 1077 | ] |
||
| 1078 | ); |
||
| 1079 | |||
| 1080 | $systemTagTable->addColumn( |
||
| 1081 | 'editable', |
||
| 1082 | Type::SMALLINT, |
||
| 1083 | [ |
||
| 1084 | 'default' => 1 |
||
| 1085 | ] |
||
| 1086 | ); |
||
| 1087 | |||
| 1088 | $systemTagTable->setPrimaryKey(['id']); |
||
| 1089 | $systemTagTable->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
||
| 1090 | |||
| 1091 | } |
||
| 1092 | |||
| 1093 | if (!$schema->hasTable("${prefix}systemtag_object_mapping")) { |
||
| 1094 | $systemTagObjectMappingTable = $schema->createTable("${prefix}systemtag_object_mapping"); |
||
| 1095 | |||
| 1096 | $systemTagObjectMappingTable->addColumn( |
||
| 1097 | 'objectid', |
||
| 1098 | Type::STRING, |
||
| 1099 | [ |
||
| 1100 | 'default' => '', |
||
| 1101 | 'length' => 64 |
||
| 1102 | ] |
||
| 1103 | ); |
||
| 1104 | |||
| 1105 | $systemTagObjectMappingTable->addColumn( |
||
| 1106 | 'objecttype', |
||
| 1107 | Type::STRING, |
||
| 1108 | [ |
||
| 1109 | 'default' => '', |
||
| 1110 | 'length' => 64 |
||
| 1111 | ] |
||
| 1112 | ); |
||
| 1113 | |||
| 1114 | $systemTagObjectMappingTable->addColumn( |
||
| 1115 | 'systemtagid', |
||
| 1116 | Type::INTEGER, |
||
| 1117 | [ |
||
| 1118 | 'default' => 0, |
||
| 1119 | 'notnull' => true, |
||
| 1120 | 'unsigned' => true |
||
| 1121 | ] |
||
| 1122 | ); |
||
| 1123 | |||
| 1124 | $systemTagObjectMappingTable->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
||
| 1125 | |||
| 1126 | } |
||
| 1127 | |||
| 1128 | if ($schema->hasTable("${prefix}file_map")) { |
||
| 1129 | $schema->dropTable("${prefix}file_map"); |
||
| 1130 | } |
||
| 1131 | |||
| 1132 | View Code Duplication | if ($schema->hasTable("${prefix}filecache")) { |
|
|
|
|||
| 1133 | $fileCacheTable = $schema->getTable("${prefix}filecache"); |
||
| 1134 | |||
| 1135 | if (!$fileCacheTable->hasColumn('checksum')) { |
||
| 1136 | $fileCacheTable->addColumn( |
||
| 1137 | 'checksum', |
||
| 1138 | Type::STRING, |
||
| 1139 | [ |
||
| 1140 | 'default' => null, |
||
| 1141 | 'length' => 255, |
||
| 1142 | 'notnull' => false |
||
| 1143 | ] |
||
| 1144 | ); |
||
| 1145 | } |
||
| 1146 | |||
| 1147 | } |
||
| 1148 | |||
| 1149 | View Code Duplication | if ($schema->hasTable("${prefix}share")) { |
|
| 1150 | $shareTable = $schema->getTable("${prefix}share"); |
||
| 1151 | |||
| 1152 | if (!$shareTable->hasColumn('uid_initiator')) { |
||
| 1153 | $shareTable->addColumn( |
||
| 1154 | 'uid_initiator', |
||
| 1155 | Type::STRING, |
||
| 1156 | [ |
||
| 1157 | 'default' => null, |
||
| 1158 | 'length' => 64, |
||
| 1159 | 'notnull' => false |
||
| 1160 | ] |
||
| 1161 | ); |
||
| 1162 | } |
||
| 1163 | } |
||
| 1164 | } |
||
| 1165 | } |
||
| 1166 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.