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