Set up migration environment with alembic
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
"""inital revision
|
||||
|
||||
Revision ID: 299a83240036
|
||||
Revises:
|
||||
Create Date: 2025-10-12 20:46:13.452705
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "299a83240036"
|
||||
down_revision: Union[str, Sequence[str], None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"event",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("title", sa.String(), nullable=False),
|
||||
sa.Column("event_time", sa.DateTime(), nullable=False),
|
||||
sa.Column("registration_deadline", sa.DateTime(), nullable=False),
|
||||
sa.Column("description", sa.String(), nullable=False),
|
||||
sa.Column("recipe_link", sa.String(), nullable=False),
|
||||
sa.Column("team_cooking_min", sa.Integer(), nullable=False),
|
||||
sa.Column("team_cooking_max", sa.Integer(), nullable=False),
|
||||
sa.Column("team_dishes_min", sa.Integer(), nullable=False),
|
||||
sa.Column("team_dishes_max", sa.Integer(), nullable=False),
|
||||
sa.Column("team_prep_min", sa.Integer(), nullable=False),
|
||||
sa.Column("team_prep_max", sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"household",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("name", sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_table(
|
||||
"registration",
|
||||
sa.Column("event_id", sa.Integer(), nullable=False),
|
||||
sa.Column("household_id", sa.Integer(), nullable=False),
|
||||
sa.Column("num_adult_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("num_children_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("num_small_children_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("comment", sa.String(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["event_id"],
|
||||
["event.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["household_id"],
|
||||
["household.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("event_id", "household_id"),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"subscription",
|
||||
sa.Column("household_id", sa.Integer(), nullable=False),
|
||||
sa.Column("num_adult_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("num_children_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("num_small_children_meals", sa.Integer(), nullable=False),
|
||||
sa.Column("comment", sa.String(), nullable=True),
|
||||
sa.Column("last_modified", sa.DateTime(), nullable=False),
|
||||
sa.Column("monday", sa.Boolean(), nullable=False),
|
||||
sa.Column("tuesday", sa.Boolean(), nullable=False),
|
||||
sa.Column("wednesday", sa.Boolean(), nullable=False),
|
||||
sa.Column("thursday", sa.Boolean(), nullable=False),
|
||||
sa.Column("friday", sa.Boolean(), nullable=False),
|
||||
sa.Column("saturday", sa.Boolean(), nullable=False),
|
||||
sa.Column("sunday", sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["household_id"],
|
||||
["household.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("household_id"),
|
||||
)
|
||||
op.create_table(
|
||||
"team_registration",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("event_id", sa.Integer(), nullable=False),
|
||||
sa.Column("person_name", sa.String(), nullable=False),
|
||||
sa.Column("work_type", sa.Text(), nullable=False),
|
||||
sa.Column("comment", sa.String(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["event_id"],
|
||||
["event.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table("team_registration")
|
||||
op.drop_table("subscription")
|
||||
op.drop_table("registration")
|
||||
op.drop_table("household")
|
||||
op.drop_table("event")
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user