"""adding tags and new cols

Revision ID: 1c50cbfc423a
Revises: 2d11cf5992b7
Create Date: 2020-10-09 17:38:52.011780

"""
import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = "1c50cbfc423a"
down_revision = "2d11cf5992b7"
branch_labels = None
depends_on = None


def upgrade():
    schema_upgrades()


#     data_upgrades()


def downgrade():
    data_downgrades()


#     schema_downgrades()


def schema_upgrades():
    """schema upgrade migrations go here."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "tag",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column(
            "insert_datetime",
            sa.DateTime(),
            server_default=sa.text("now()"),
            nullable=False,
        ),
        sa.Column("name", sa.String(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_tag_id"), "tag", ["id"], unique=False)
    op.create_index(op.f("ix_tag_name"), "tag", ["name"], unique=False)
    op.create_table(
        "restaurant_tag_association",
        sa.Column("restaurant_id", sa.Integer(), nullable=True),
        sa.Column("tag_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["restaurant_id"], ["restaurant.id"]),
        sa.ForeignKeyConstraint(["tag_id"], ["tag.id"]),
    )
    op.add_column(
        "restaurant",
        sa.Column(
            "for_drink",
            sa.Boolean(),
            server_default=sa.text("true"),
            nullable=False,
        ),
    )
    op.add_column(
        "restaurant",
        sa.Column(
            "for_food",
            sa.Boolean(),
            server_default=sa.text("true"),
            nullable=False,
        ),
    )
    op.add_column(
        "restaurant",
        sa.Column(
            "is_archived",
            sa.Boolean(),
            server_default=sa.text("false"),
            nullable=False,
        ),
    )
    # ### end Alembic commands ###


def schema_downgrades():
    """schema downgrade migrations go here."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("restaurant", "is_archived")
    op.drop_column("restaurant", "for_food")
    op.drop_column("restaurant", "for_drink")
    op.drop_table("restaurant_tag_association")
    op.drop_index(op.f("ix_tag_name"), table_name="tag")
    op.drop_index(op.f("ix_tag_id"), table_name="tag")
    op.drop_table("tag")
    # ### end Alembic commands ###


def data_upgrades():
    """Add any optional data upgrade migrations here!"""
    pass


def data_downgrades():
    """Add any optional data downgrade migrations here!"""
    pass
