haldis/app/migrations/versions/150252c1cdb1_.py
2019-09-05 03:33:29 +02:00

81 lines
2.9 KiB
Python

"""empty message
Revision ID: 150252c1cdb1
Revises: None
Create Date: 2019-04-02 18:00:12.618368
"""
# revision identifiers, used by Alembic.
revision = "150252c1cdb1"
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"location",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(length=120), nullable=False),
sa.Column("address", sa.String(length=254), nullable=True),
sa.Column("website", sa.String(length=120), nullable=True),
sa.Column("telephone", sa.String(length=20), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("username", sa.String(length=80), nullable=False),
sa.Column("admin", sa.Boolean(), nullable=True),
sa.Column("bias", sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("username"),
)
op.create_table(
"order",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("courrier_id", sa.Integer(), nullable=True),
sa.Column("location_id", sa.Integer(), nullable=True),
sa.Column("starttime", sa.DateTime(), nullable=True),
sa.Column("stoptime", sa.DateTime(), nullable=True),
sa.Column("public", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(["location_id"], ["location.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"product",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("location_id", sa.Integer(), nullable=True),
sa.Column("name", sa.String(length=120), nullable=False),
sa.Column("price", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(["location_id"], ["location.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"order_item",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("order_id", sa.Integer(), nullable=False),
sa.Column("product_id", sa.Integer(), nullable=True),
sa.Column("paid", sa.Boolean(), nullable=True),
sa.Column("extra", sa.String(length=254), nullable=True),
sa.Column("name", sa.String(length=120), nullable=True),
sa.ForeignKeyConstraint(["order_id"], ["order.id"]),
sa.ForeignKeyConstraint(["product_id"], ["product.id"]),
sa.ForeignKeyConstraint(["user_id"], ["user.id"]),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("order_item")
op.drop_table("product")
op.drop_table("order")
op.drop_table("user")
op.drop_table("location")
# ### end Alembic commands ###