kopia lustrzana https://github.com/jprochazka/adsb-receiver
SQLite upgrade fix.
rodzic
7fa44bd331
commit
b0b8ee85a8
|
|
@ -54,7 +54,7 @@
|
|||
// Change tables containing datetime data to datetime.
|
||||
if ($settings::db_driver != "xml") {
|
||||
|
||||
// ALter MySQL tables.
|
||||
// Alter MySQL tables.
|
||||
if ($settings::db_driver != "mysql") {
|
||||
$dbh = $common->pdoOpen();
|
||||
|
||||
|
|
@ -90,95 +90,6 @@
|
|||
|
||||
$dbh = NULL;
|
||||
}
|
||||
|
||||
// Convert times to GMT.
|
||||
|
||||
// You may wish to uncomment this block of code in order to convert existing times
|
||||
// stored in the database to UTC/GMT time. Before doing so it is recommended that
|
||||
// you set the setting max_execution_time setting to a large amount of time in your
|
||||
// php.ini file. Depending on the amount of flight data logged this may take quite
|
||||
// some time for this upgrade script to complete so be patient and let it run it's
|
||||
// course. Afterwards set the max_execution_time back to it previous setting.
|
||||
|
||||
/*
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."aircraft";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$aircraft = $sth->fetchAll();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
|
||||
foreach ($aircraft as $airframe) {
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "UPDATE ".$settings::db_prefix."aircraft SET firstSeen = :firstSeen, lastSeen = :lastSeen WHERE id = :id";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $airframe["firstSeen"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $airframe["lastSeen"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':id', $airframe["id"], PDO::PARAM_INT);
|
||||
$sth->execute();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
}
|
||||
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "SELECT id, date FROM ".$settings::db_prefix."blogPosts";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$blogPosts = $sth->fetchAll();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
|
||||
foreach ($blogPosts as $post) {
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "UPDATE ".$settings::db_prefix."blogPosts SET date = :date WHERE id = :id";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->bindParam(':date', gmdate("Y-m-d H:i:s", $post["date"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':id', $post["id"], PDO::PARAM_INT);
|
||||
$sth->execute();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
}
|
||||
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "SELECT id, firstSeen, lastSeen FROM ".$settings::db_prefix."flights";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$flights = $sth->fetchAll();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
|
||||
foreach ($flights as $flight) {
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "UPDATE ".$settings::db_prefix."flights SET firstSeen = :firstSeen, lastSeen = lastSeen WHERE id = :id";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->bindParam(':firstSeen', gmdate("Y-m-d H:i:s", $flight["firstSeen"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':lastSeen', gmdate("Y-m-d H:i:s", $flight["lastSeen"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':id', $flight["id"], PDO::PARAM_INT);
|
||||
$sth->execute();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
}
|
||||
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "SELECT id, time FROM ".$settings::db_prefix."positions";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$positionss = $sth->fetchAll();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$dbh = $common->pdoOpen();
|
||||
$sql = "UPDATE ".$settings::db_prefix."positions SET time = :time WHERE id = :id";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->bindParam(':time', gmdate("Y-m-d H:i:s", $position["time"]), PDO::PARAM_STR);
|
||||
$sth->bindParam(':id', $position["id"], PDO::PARAM_INT);
|
||||
$sth->execute();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Add timezone setting.
|
||||
|
|
@ -239,19 +150,12 @@
|
|||
|
||||
if ($settings::db_driver == "sqlite") {
|
||||
// In SQLite aircraft.flight should have been an INTEGER not TEXT column.
|
||||
// Since SQLite does not fully support ALTER TABEL allowing the change to be done easily this change will be skipped.
|
||||
// Since SQLite does not fully support ALTER TABLE allowing the change to be done easily this change will be skipped.
|
||||
// This change will be addressed in the future if a problem arises with this column not being specifed as an INTEGER.
|
||||
|
||||
// Add the column positions.aircraft.
|
||||
$dbh = $common->pdoOpen();
|
||||
|
||||
$sql = "ALTER TABLE ".$settings::db_prefix."positions ADD COLUMN aircraft INTEGER";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$sth = NULL;
|
||||
$dbh = NULL;
|
||||
|
||||
// Add FAA database tables.
|
||||
// The FAA database will not be used.
|
||||
// These tables will be remove in the future once it is known it will not effect the portal once removed.
|
||||
$faaMasterSql = 'CREATE TABLE '.$dbPrefix.'faa_master (
|
||||
nNumber VARCHAR(5) NOT NULL,
|
||||
serialNumber VARCHAR(30) NULL,
|
||||
|
|
@ -322,7 +226,6 @@
|
|||
}
|
||||
|
||||
if ($settings::db_driver == "mysql") {
|
||||
|
||||
// Added check to see if column already exists.
|
||||
$dbh = $common->pdoOpen();
|
||||
if (count($dbh->query("SHOW COLUMNS FROM `".$settings::db_prefix."positions` LIKE 'aircraft'")->fetchAll())) {
|
||||
|
|
@ -334,7 +237,6 @@
|
|||
//$dbh = NULL;
|
||||
}
|
||||
$dbh = NULL;
|
||||
|
||||
}
|
||||
}
|
||||
$common->updateSetting("version", "2.1.0");
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue