"""Initial revision

Revision ID: 87d4ea0aa91d
Revises: 
Create Date: 2019-10-11 18:30:19.666242

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "87d4ea0aa91d"
down_revision = "0"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "source",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("path", sa.String(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("path"),
    )
    op.create_table(
        "formula",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.Text(), nullable=True),
        sa.Column("source_id", sa.Integer(), nullable=False),
        sa.Column("json", sa.JSON(), nullable=True),
        sa.ForeignKeyConstraint(["source_id"], ["source.id"]),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "problem",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("source_id", sa.Integer(), nullable=False),
        sa.Column("conjecture_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["conjecture_id"], ["formula.id"]),
        sa.ForeignKeyConstraint(["source_id"], ["source.id"]),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "association",
        sa.Column("left_id", sa.Integer(), nullable=False),
        sa.Column("right_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["left_id"], ["problem.id"]),
        sa.ForeignKeyConstraint(["right_id"], ["formula.id"]),
    )
    op.create_table(
        "solution",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("problem_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["problem_id"], ["problem.id"]),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "solution_item",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("solution_id", sa.Integer(), nullable=False),
        sa.Column("premise_id", sa.Integer(), nullable=False),
        sa.Column("used", sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(["premise_id"], ["formula.id"]),
        sa.ForeignKeyConstraint(["solution_id"], ["solution.id"]),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("solution_item")
    op.drop_table("solution")
    op.drop_table("association")
    op.drop_table("problem")
    op.drop_table("formula")
    op.drop_table("source")
    # ### end Alembic commands ###
