"""empty message

Revision ID: fd7794ece0b3
Revises: 975c22ae802b
Create Date: 2020-07-17 19:51:08.457429

"""
import sqlalchemy as sa
import sqlalchemy_utils
from alembic import op

from project import dbtypes

# revision identifiers, used by Alembic.
revision = "fd7794ece0b3"
down_revision = "975c22ae802b"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "eventplace",
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.Unicode(length=255), nullable=False),
        sa.Column("location_id", sa.Integer(), nullable=True),
        sa.Column("photo_id", sa.Integer(), nullable=True),
        sa.Column("url", sa.String(length=255), nullable=True),
        sa.Column("description", sa.UnicodeText(), nullable=True),
        sa.Column("created_by_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ["created_by_id"],
            ["user.id"],
        ),
        sa.ForeignKeyConstraint(
            ["location_id"],
            ["location.id"],
        ),
        sa.ForeignKeyConstraint(
            ["photo_id"],
            ["image.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.add_column("event", sa.Column("event_place_id", sa.Integer(), nullable=True))
    op.create_foreign_key(None, "event", "place", ["event_place_id"], ["id"])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "event", type_="foreignkey")
    op.drop_column("event", "event_place_id")
    op.drop_table("eventplace")
    # ### end Alembic commands ###
