"""initial db Revision ID: 52bdefdbf755 Revises: Create Date: 2024-05-27 13:59:24.644977 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "52bdefdbf755" down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table( "tenants", sa.Column("id", sa.Integer(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("hostname", sa.String(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint("id"), ) op.create_table( "aircraft", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("icao", sa.String(), nullable=False), sa.Column("tail_number", sa.String(), nullable=True), sa.Column("range_nm", sa.Integer(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("icao", "tail_number"), ) op.create_table( "airlines", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("iata", sa.String(), nullable=False), sa.Column("icao", sa.String(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("id"), ) op.create_table( "airports", sa.Column("icao", sa.String(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("iata", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("city", sa.String(), nullable=False), sa.Column("country", sa.String(), nullable=False), sa.Column("latitude", sa.Float(), nullable=False), sa.Column("longitude", sa.Float(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("icao"), ) op.create_table( "users", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("email", sa.String(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("id"), ) op.create_table( "flights", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("departure_icao", sa.String(), nullable=False), sa.Column("arrival_icao", sa.String(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.Column("aircraft_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["aircraft_id"], ["aircraft.id"], ), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("id"), ) op.create_table( "livery", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tenant_id", sa.Integer(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("aircraft_id", sa.Integer(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint( ["aircraft_id"], ["aircraft.id"], ), sa.ForeignKeyConstraint( ["tenant_id"], ["tenants.id"], ), sa.PrimaryKeyConstraint("id"), ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table("livery") op.drop_table("flights") op.drop_table("users") op.drop_table("airports") op.drop_table("airlines") op.drop_table("aircraft") op.drop_table("tenants") # ### end Alembic commands ###