Skip to content

Commit b8b821e

Browse files
committed
stub out v1 api
1 parent f56de15 commit b8b821e

12 files changed

+719
-41
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.mypy_cache/
22
.pytest_cache/
33
.ruff_cache/
4+
notes.txt
5+

alembic/versions/d487ed348c4c_add_user.py

-37
This file was deleted.
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
"""initial db
2+
3+
Revision ID: f7e18415a029
4+
Revises:
5+
Create Date: 2024-05-27 13:51:26.815340
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
import sqlalchemy as sa
12+
13+
from alembic import op
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "f7e18415a029"
17+
down_revision: Union[str, None] = None
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.create_table(
25+
"tenants",
26+
sa.Column("id", sa.Integer(), nullable=False),
27+
sa.Column("name", sa.String(), nullable=False),
28+
sa.Column("hostname", sa.String(), nullable=False),
29+
sa.Column("created_at", sa.DateTime(), nullable=False),
30+
sa.PrimaryKeyConstraint("id"),
31+
)
32+
op.create_table(
33+
"aircraft",
34+
sa.Column("id", sa.Integer(), nullable=False),
35+
sa.Column("tenant_id", sa.Integer(), nullable=False),
36+
sa.Column("icao", sa.String(), nullable=False),
37+
sa.Column("tail_number", sa.String(), nullable=True),
38+
sa.Column("range_nm", sa.Integer(), nullable=False),
39+
sa.Column("created_at", sa.DateTime(), nullable=False),
40+
sa.ForeignKeyConstraint(
41+
["tenant_id"],
42+
["tenants.id"],
43+
),
44+
sa.PrimaryKeyConstraint("id"),
45+
sa.UniqueConstraint("icao", "tail_number"),
46+
)
47+
op.create_table(
48+
"airlines",
49+
sa.Column("id", sa.Integer(), nullable=False),
50+
sa.Column("tenant_id", sa.Integer(), nullable=False),
51+
sa.Column("name", sa.String(), nullable=False),
52+
sa.Column("iata", sa.String(), nullable=False),
53+
sa.Column("icao", sa.String(), nullable=False),
54+
sa.Column("created_at", sa.DateTime(), nullable=False),
55+
sa.ForeignKeyConstraint(
56+
["tenant_id"],
57+
["tenants.id"],
58+
),
59+
sa.PrimaryKeyConstraint("id"),
60+
)
61+
op.create_table(
62+
"airports",
63+
sa.Column("icao", sa.String(), nullable=False),
64+
sa.Column("tenant_id", sa.Integer(), nullable=False),
65+
sa.Column("iata", sa.String(), nullable=False),
66+
sa.Column("name", sa.String(), nullable=False),
67+
sa.Column("city", sa.String(), nullable=False),
68+
sa.Column("country", sa.String(), nullable=False),
69+
sa.Column("latitude", sa.Float(), nullable=False),
70+
sa.Column("longitude", sa.Float(), nullable=False),
71+
sa.Column("created_at", sa.DateTime(), nullable=False),
72+
sa.ForeignKeyConstraint(
73+
["tenant_id"],
74+
["tenants.id"],
75+
),
76+
sa.PrimaryKeyConstraint("icao"),
77+
)
78+
op.create_table(
79+
"flights",
80+
sa.Column("id", sa.Integer(), nullable=False),
81+
sa.Column("tenant_id", sa.Integer(), nullable=False),
82+
sa.Column("departure_icao", sa.String(), nullable=False),
83+
sa.Column("arrival_icao", sa.String(), nullable=False),
84+
sa.Column("created_at", sa.DateTime(), nullable=False),
85+
sa.ForeignKeyConstraint(
86+
["tenant_id"],
87+
["tenants.id"],
88+
),
89+
sa.PrimaryKeyConstraint("id"),
90+
)
91+
op.create_table(
92+
"users",
93+
sa.Column("id", sa.Integer(), nullable=False),
94+
sa.Column("tenant_id", sa.Integer(), nullable=False),
95+
sa.Column("name", sa.String(), nullable=False),
96+
sa.Column("email", sa.String(), nullable=False),
97+
sa.Column("created_at", sa.DateTime(), nullable=False),
98+
sa.ForeignKeyConstraint(
99+
["tenant_id"],
100+
["tenants.id"],
101+
),
102+
sa.PrimaryKeyConstraint("id"),
103+
)
104+
op.create_table(
105+
"livery",
106+
sa.Column("id", sa.Integer(), nullable=False),
107+
sa.Column("tenant_id", sa.Integer(), nullable=False),
108+
sa.Column("name", sa.String(), nullable=False),
109+
sa.Column("aircraft_id", sa.Integer(), nullable=False),
110+
sa.Column("created_at", sa.DateTime(), nullable=False),
111+
sa.ForeignKeyConstraint(
112+
["aircraft_id"],
113+
["aircraft.id"],
114+
),
115+
sa.ForeignKeyConstraint(
116+
["tenant_id"],
117+
["tenants.id"],
118+
),
119+
sa.PrimaryKeyConstraint("id"),
120+
)
121+
# ### end Alembic commands ###
122+
123+
124+
def downgrade() -> None:
125+
# ### commands auto generated by Alembic - please adjust! ###
126+
op.drop_table("livery")
127+
op.drop_table("users")
128+
op.drop_table("flights")
129+
op.drop_table("airports")
130+
op.drop_table("airlines")
131+
op.drop_table("aircraft")
132+
op.drop_table("tenants")
133+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)