|
@@ 119-141 (lines=23) @@
|
| 116 |
|
return $error; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
private static function update_from_2() { |
| 120 |
|
$Connection = new Connection(); |
| 121 |
|
// Add new column decode to acars_live table |
| 122 |
|
$query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
| 123 |
|
try { |
| 124 |
|
$sth = $Connection->db->prepare($query); |
| 125 |
|
$sth->execute(); |
| 126 |
|
} catch(PDOException $e) { |
| 127 |
|
return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
| 128 |
|
} |
| 129 |
|
$error = ''; |
| 130 |
|
// Create table acars_archive |
| 131 |
|
$error .= create_db::import_file('../db/acars_archive.sql'); |
| 132 |
|
// Update schema_version to 3 |
| 133 |
|
$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
| 134 |
|
try { |
| 135 |
|
$sth = $Connection->db->prepare($query); |
| 136 |
|
$sth->execute(); |
| 137 |
|
} catch(PDOException $e) { |
| 138 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 139 |
|
} |
| 140 |
|
return $error; |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
private static function update_from_3() { |
| 144 |
|
$Connection = new Connection(); |
|
@@ 329-353 (lines=25) @@
|
| 326 |
|
return $error; |
| 327 |
|
} |
| 328 |
|
|
| 329 |
|
private static function update_from_8() { |
| 330 |
|
$Connection = new Connection(); |
| 331 |
|
$error = ''; |
| 332 |
|
// Update table aircraft |
| 333 |
|
$error .= create_db::import_file('../db/notam.sql'); |
| 334 |
|
if ($error != '') return $error; |
| 335 |
|
$query = "DELETE FROM config WHERE name = 'last_update_db'; |
| 336 |
|
INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
| 337 |
|
DELETE FROM config WHERE name = 'last_update_notam_db'; |
| 338 |
|
INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
| 339 |
|
try { |
| 340 |
|
$sth = $Connection->db->prepare($query); |
| 341 |
|
$sth->execute(); |
| 342 |
|
} catch(PDOException $e) { |
| 343 |
|
return "error (insert last_update values) : ".$e->getMessage()."\n"; |
| 344 |
|
} |
| 345 |
|
$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
| 346 |
|
try { |
| 347 |
|
$sth = $Connection->db->prepare($query); |
| 348 |
|
$sth->execute(); |
| 349 |
|
} catch(PDOException $e) { |
| 350 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 351 |
|
} |
| 352 |
|
return $error; |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
private static function update_from_9() { |
| 356 |
|
$Connection = new Connection(); |
|
@@ 355-378 (lines=24) @@
|
| 352 |
|
return $error; |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
private static function update_from_9() { |
| 356 |
|
$Connection = new Connection(); |
| 357 |
|
$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
| 358 |
|
ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
| 359 |
|
try { |
| 360 |
|
$sth = $Connection->db->prepare($query); |
| 361 |
|
$sth->execute(); |
| 362 |
|
} catch(PDOException $e) { |
| 363 |
|
return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
| 364 |
|
} |
| 365 |
|
$error = ''; |
| 366 |
|
// Update table atc |
| 367 |
|
$error .= create_db::import_file('../db/atc.sql'); |
| 368 |
|
if ($error != '') return $error; |
| 369 |
|
|
| 370 |
|
$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
| 371 |
|
try { |
| 372 |
|
$sth = $Connection->db->prepare($query); |
| 373 |
|
$sth->execute(); |
| 374 |
|
} catch(PDOException $e) { |
| 375 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 376 |
|
} |
| 377 |
|
return $error; |
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
private static function update_from_10() { |
| 381 |
|
$Connection = new Connection(); |
|
@@ 495-514 (lines=20) @@
|
| 492 |
|
return $error; |
| 493 |
|
} |
| 494 |
|
|
| 495 |
|
private static function update_from_13() { |
| 496 |
|
$Connection = new Connection(); |
| 497 |
|
$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
| 498 |
|
try { |
| 499 |
|
$sth = $Connection->db->prepare($query); |
| 500 |
|
$sth->execute(); |
| 501 |
|
} catch(PDOException $e) { |
| 502 |
|
return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
| 503 |
|
} |
| 504 |
|
|
| 505 |
|
$error = ''; |
| 506 |
|
$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
| 507 |
|
try { |
| 508 |
|
$sth = $Connection->db->prepare($query); |
| 509 |
|
$sth->execute(); |
| 510 |
|
} catch(PDOException $e) { |
| 511 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 512 |
|
} |
| 513 |
|
return $error; |
| 514 |
|
} |
| 515 |
|
|
| 516 |
|
private static function update_from_14() { |
| 517 |
|
$Connection = new Connection(); |
|
@@ 533-553 (lines=21) @@
|
| 530 |
|
} |
| 531 |
|
|
| 532 |
|
|
| 533 |
|
private static function update_from_15() { |
| 534 |
|
$Connection = new Connection(); |
| 535 |
|
$error = ''; |
| 536 |
|
// Add tables |
| 537 |
|
$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
| 538 |
|
try { |
| 539 |
|
$sth = $Connection->db->prepare($query); |
| 540 |
|
$sth->execute(); |
| 541 |
|
} catch(PDOException $e) { |
| 542 |
|
return "error (update stats) : ".$e->getMessage()."\n"; |
| 543 |
|
} |
| 544 |
|
if ($error != '') return $error; |
| 545 |
|
$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 546 |
|
try { |
| 547 |
|
$sth = $Connection->db->prepare($query); |
| 548 |
|
$sth->execute(); |
| 549 |
|
} catch(PDOException $e) { |
| 550 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 551 |
|
} |
| 552 |
|
return $error; |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
private static function update_from_16() { |
| 556 |
|
$Connection = new Connection(); |
|
@@ 587-607 (lines=21) @@
|
| 584 |
|
} |
| 585 |
|
return $error; |
| 586 |
|
} |
| 587 |
|
private static function update_from_18() { |
| 588 |
|
$Connection = new Connection(); |
| 589 |
|
$error = ''; |
| 590 |
|
// Modify stats_airport table |
| 591 |
|
$query = "ALTER TABLE `stats_airport` ADD `type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
| 592 |
|
try { |
| 593 |
|
$sth = $Connection->db->prepare($query); |
| 594 |
|
$sth->execute(); |
| 595 |
|
} catch(PDOException $e) { |
| 596 |
|
return "error (update stats) : ".$e->getMessage()."\n"; |
| 597 |
|
} |
| 598 |
|
if ($error != '') return $error; |
| 599 |
|
$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 600 |
|
try { |
| 601 |
|
$sth = $Connection->db->prepare($query); |
| 602 |
|
$sth->execute(); |
| 603 |
|
} catch(PDOException $e) { |
| 604 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 605 |
|
} |
| 606 |
|
return $error; |
| 607 |
|
} |
| 608 |
|
|
| 609 |
|
private static function update_from_19() { |
| 610 |
|
$Connection = new Connection(); |
|
@@ 686-706 (lines=21) @@
|
| 683 |
|
return $error; |
| 684 |
|
} |
| 685 |
|
|
| 686 |
|
private static function update_from_21() { |
| 687 |
|
$Connection = new Connection(); |
| 688 |
|
$error = ''; |
| 689 |
|
// Rename type to stats_type |
| 690 |
|
$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
| 691 |
|
try { |
| 692 |
|
$sth = $Connection->db->prepare($query); |
| 693 |
|
$sth->execute(); |
| 694 |
|
} catch(PDOException $e) { |
| 695 |
|
return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 696 |
|
} |
| 697 |
|
if ($error != '') return $error; |
| 698 |
|
$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 699 |
|
try { |
| 700 |
|
$sth = $Connection->db->prepare($query); |
| 701 |
|
$sth->execute(); |
| 702 |
|
} catch(PDOException $e) { |
| 703 |
|
return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 704 |
|
} |
| 705 |
|
return $error; |
| 706 |
|
} |
| 707 |
|
|
| 708 |
|
private static function update_from_22() { |
| 709 |
|
global $globalDBdriver; |