# pylint: disable=invalid-name
"""JurisdictionResult

Revision ID: 22c615fe67ab
Revises: 5b7164faeda5
Create Date: 2020-07-28 23:32:34.385481+00:00

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "22c615fe67ab"
down_revision = "5b7164faeda5"
branch_labels = None
depends_on = None


def upgrade():
    op.create_primary_key(
        "contest_jurisdiction_pkey",
        "contest_jurisdiction",
        ["contest_id", "jurisdiction_id"],
    )
    op.create_table(
        "jurisdiction_result",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("round_id", sa.String(length=200), nullable=False),
        sa.Column("contest_id", sa.String(length=200), nullable=False),
        sa.Column("jurisdiction_id", sa.String(length=200), nullable=False),
        sa.Column("contest_choice_id", sa.String(length=200), nullable=False),
        sa.Column("result", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["contest_choice_id"],
            ["contest_choice.id"],
            name=op.f("jurisdiction_result_contest_choice_id_fkey"),
            ondelete="cascade",
        ),
        sa.ForeignKeyConstraint(
            ["contest_id"],
            ["contest.id"],
            name=op.f("jurisdiction_result_contest_id_fkey"),
            ondelete="cascade",
        ),
        sa.ForeignKeyConstraint(
            ["jurisdiction_id"],
            ["jurisdiction.id"],
            name=op.f("jurisdiction_result_jurisdiction_id_fkey"),
            ondelete="cascade",
        ),
        sa.ForeignKeyConstraint(
            ["round_id"],
            ["round.id"],
            name=op.f("jurisdiction_result_round_id_fkey"),
            ondelete="cascade",
        ),
        sa.PrimaryKeyConstraint(
            "round_id",
            "jurisdiction_id",
            "contest_choice_id",
            name=op.f("jurisdiction_result_pkey"),
        ),
        sa.ForeignKeyConstraint(
            ["contest_id", "jurisdiction_id"],
            ["contest_jurisdiction.contest_id", "contest_jurisdiction.jurisdiction_id"],
            name=op.f("jurisdiction_result_contest_id_jurisdiction_id_fkey"),
            ondelete="cascade",
        ),
    )


def downgrade():  # pragma: no cover
    pass
    # # ### commands auto generated by Alembic - please adjust! ###
    # op.drop_table("jurisdiction_result")
    # # ### end Alembic commands ###
