Inital stab at local flights
This commit is contained in:
35
backend/app/models/local_flight.py
Normal file
35
backend/app/models/local_flight.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Text, Enum as SQLEnum, BigInteger
|
||||
from sqlalchemy.sql import func
|
||||
from enum import Enum
|
||||
from app.db.session import Base
|
||||
|
||||
|
||||
class LocalFlightType(str, Enum):
|
||||
LOCAL = "LOCAL"
|
||||
CIRCUITS = "CIRCUITS"
|
||||
DEPARTURE = "DEPARTURE"
|
||||
|
||||
|
||||
class LocalFlightStatus(str, Enum):
|
||||
BOOKED_OUT = "BOOKED_OUT"
|
||||
DEPARTED = "DEPARTED"
|
||||
LANDED = "LANDED"
|
||||
CANCELLED = "CANCELLED"
|
||||
|
||||
|
||||
class LocalFlight(Base):
|
||||
__tablename__ = "local_flights"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True)
|
||||
registration = Column(String(16), nullable=False, index=True)
|
||||
type = Column(String(32), nullable=False) # Aircraft type
|
||||
callsign = Column(String(16), nullable=True)
|
||||
pob = Column(Integer, nullable=False) # Persons on board
|
||||
flight_type = Column(SQLEnum(LocalFlightType), nullable=False, index=True)
|
||||
status = Column(SQLEnum(LocalFlightStatus), nullable=False, default=LocalFlightStatus.BOOKED_OUT, index=True)
|
||||
notes = Column(Text, nullable=True)
|
||||
booked_out_dt = Column(DateTime, nullable=False, server_default=func.current_timestamp(), index=True)
|
||||
departure_dt = Column(DateTime, nullable=True) # Actual takeoff time
|
||||
landed_dt = Column(DateTime, nullable=True)
|
||||
created_by = Column(String(16), nullable=True, index=True)
|
||||
updated_at = Column(DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp())
|
||||
Reference in New Issue
Block a user