actual times via AeroDataBox + FlightAware runway fallback
This commit is contained in:
@@ -33,6 +33,13 @@ CREATE TABLE IF NOT EXISTS pending_flights (
|
||||
track_times TEXT,
|
||||
track_point_count INTEGER,
|
||||
flightaware_url TEXT,
|
||||
takeoff_actual TEXT,
|
||||
landing_actual TEXT,
|
||||
gate_departure_scheduled TEXT,
|
||||
gate_departure_actual TEXT,
|
||||
gate_arrival_scheduled TEXT,
|
||||
gate_arrival_actual TEXT,
|
||||
schedule_error TEXT,
|
||||
airtrail_flight_id INTEGER,
|
||||
parse_warnings TEXT,
|
||||
error_message TEXT,
|
||||
@@ -68,6 +75,29 @@ def connect():
|
||||
conn.close()
|
||||
|
||||
|
||||
# Columns added after the original schema. CREATE TABLE IF NOT EXISTS above
|
||||
# is a no-op against an already-existing table, so anything added there
|
||||
# needs a matching entry here too or it silently never appears on an
|
||||
# upgraded (vs. freshly created) database.
|
||||
MIGRATIONS = [
|
||||
("takeoff_actual", "TEXT"),
|
||||
("landing_actual", "TEXT"),
|
||||
("gate_departure_scheduled", "TEXT"),
|
||||
("gate_departure_actual", "TEXT"),
|
||||
("gate_arrival_scheduled", "TEXT"),
|
||||
("gate_arrival_actual", "TEXT"),
|
||||
("schedule_error", "TEXT"),
|
||||
]
|
||||
|
||||
|
||||
def _run_migrations(conn: sqlite3.Connection) -> None:
|
||||
existing = {row["name"] for row in conn.execute("PRAGMA table_info(pending_flights)")}
|
||||
for column, coltype in MIGRATIONS:
|
||||
if column not in existing:
|
||||
conn.execute(f"ALTER TABLE pending_flights ADD COLUMN {column} {coltype}")
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
with connect() as conn:
|
||||
conn.executescript(SCHEMA)
|
||||
_run_migrations(conn)
|
||||
|
||||
Reference in New Issue
Block a user