2018-10-21 15:34:03 +00:00
|
|
|
from sqlalchemy import Boolean, Column, Integer, SmallInteger, DateTime, ForeignKey, Index
|
2016-05-22 05:23:22 +00:00
|
|
|
from sqlalchemy.orm import relationship
|
2018-10-21 15:34:03 +00:00
|
|
|
from sqlalchemy.sql import func
|
2015-11-11 07:04:42 +00:00
|
|
|
|
2016-05-22 05:23:22 +00:00
|
|
|
from .base import Base
|
2015-11-11 07:04:42 +00:00
|
|
|
|
|
|
|
|
2016-05-22 05:23:22 +00:00
|
|
|
class TakeoffLanding(Base):
|
2018-01-11 07:35:07 +00:00
|
|
|
__tablename__ = 'takeoff_landings'
|
2015-11-11 07:04:42 +00:00
|
|
|
|
2018-01-19 18:14:57 +00:00
|
|
|
device_id = Column(Integer, ForeignKey('devices.id', ondelete='SET NULL'), primary_key=True)
|
|
|
|
airport_id = Column(Integer, ForeignKey('airports.id', ondelete='SET NULL'), primary_key=True)
|
|
|
|
timestamp = Column(DateTime, primary_key=True)
|
2016-05-22 05:23:22 +00:00
|
|
|
|
2017-12-16 14:54:04 +00:00
|
|
|
is_takeoff = Column(Boolean)
|
2018-01-21 20:06:27 +00:00
|
|
|
track = Column(SmallInteger)
|
2016-05-22 05:23:22 +00:00
|
|
|
|
|
|
|
# Relations
|
2017-12-30 09:52:47 +00:00
|
|
|
airport = relationship('Airport', foreign_keys=[airport_id], backref='takeoff_landings')
|
|
|
|
device = relationship('Device', foreign_keys=[device_id], backref='takeoff_landings')
|
2018-10-21 15:34:03 +00:00
|
|
|
|
|
|
|
Index('ix_takeoff_landings_date_device_id_airport_id_timestamp', func.date(TakeoffLanding.timestamp), TakeoffLanding.device_id, TakeoffLanding.airport_id, TakeoffLanding.timestamp)
|
|
|
|
Index('ix_takeoff_landings_date_device_id_timestamp_airport_id', func.date(TakeoffLanding.timestamp), TakeoffLanding.device_id, TakeoffLanding.timestamp, TakeoffLanding.airport_id)
|