"""empty message

Revision ID: 8ffe54b386b1
Revises:
Create Date: 2021-06-27 21:16:46.842009

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "8ffe54b386b1"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "author",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("first_name", sa.String(length=40), nullable=False),
        sa.Column("last_name", sa.String(length=40), nullable=False),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("first_name", "last_name"),
    )
    op.create_index(
        "_author_index", "author", ["first_name", "last_name"], unique=False
    )
    op.create_table(
        "book",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=50), nullable=False),
        sa.Column("year", sa.Integer(), nullable=True),
        sa.Column("author_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["author_id"], ["author.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("name", "year", "author_id"),
    )
    op.create_index("_book_index", "book", ["name", "year", "author_id"], unique=False)
    op.create_index(op.f("ix_book_name"), "book", ["name"], unique=False)
    op.create_index(op.f("ix_book_year"), "book", ["year"], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_book_year"), table_name="book")
    op.drop_index(op.f("ix_book_name"), table_name="book")
    op.drop_index("_book_index", table_name="book")
    op.drop_table("book")
    op.drop_index("_author_index", table_name="author")
    op.drop_table("author")
    # ### end Alembic commands ###
