Circuits handling
This commit is contained in:
@@ -108,12 +108,30 @@ def upgrade() -> None:
|
||||
op.create_index('idx_arr_created_dt', 'arrivals', ['created_dt'])
|
||||
op.create_index('idx_arr_eta', 'arrivals', ['eta'])
|
||||
op.create_index('idx_arr_created_by', 'arrivals', ['created_by'])
|
||||
|
||||
# Create circuits table for tracking touch-and-go events during circuit training
|
||||
op.create_table('circuits',
|
||||
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
|
||||
sa.Column('local_flight_id', sa.BigInteger(), nullable=False),
|
||||
sa.Column('circuit_timestamp', sa.DateTime(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.ForeignKeyConstraint(['local_flight_id'], ['local_flights.id'], ondelete='CASCADE'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci'
|
||||
)
|
||||
|
||||
# Create indexes for circuits
|
||||
op.create_index('idx_circuit_local_flight_id', 'circuits', ['local_flight_id'])
|
||||
op.create_index('idx_circuit_timestamp', 'circuits', ['circuit_timestamp'])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""
|
||||
Drop the local_flights, departures, and arrivals tables.
|
||||
Drop the circuits, arrivals, departures, and local_flights tables.
|
||||
"""
|
||||
op.drop_table('circuits')
|
||||
op.drop_table('arrivals')
|
||||
op.drop_table('departures')
|
||||
op.drop_table('local_flights')
|
||||
|
||||
Reference in New Issue
Block a user