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

Revision ID: 848293b46b37
Revises: 5004a93f75d8
Create Date: 2022-09-08 23:30:09.987750+00:00

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "848293b46b37"
down_revision = "34939a0c9f5c"
branch_labels = None
depends_on = None


def upgrade():
    op.create_table(
        "batch_inventory_data",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("jurisdiction_id", sa.String(length=200), nullable=False),
        sa.Column("cvr_file_id", sa.String(length=200), nullable=True),
        sa.Column("tabulator_status_file_id", sa.String(length=200), nullable=True),
        sa.Column("election_results", sa.JSON(), nullable=True),
        sa.Column("tabulator_id_to_name", sa.JSON(), nullable=True),
        sa.Column("sign_off_user_id", sa.String(length=200), nullable=True),
        sa.Column("signed_off_at", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(
            ["cvr_file_id"],
            ["file.id"],
            name=op.f("batch_inventory_data_cvr_file_id_fkey"),
            ondelete="set null",
        ),
        sa.ForeignKeyConstraint(
            ["jurisdiction_id"],
            ["jurisdiction.id"],
            name=op.f("batch_inventory_data_jurisdiction_id_fkey"),
            ondelete="cascade",
        ),
        sa.ForeignKeyConstraint(
            ["sign_off_user_id"],
            ["user.id"],
            name=op.f("batch_inventory_data_sign_off_user_id_fkey"),
            ondelete="set null",
        ),
        sa.ForeignKeyConstraint(
            ["tabulator_status_file_id"],
            ["file.id"],
            name=op.f("batch_inventory_data_tabulator_status_file_id_fkey"),
            ondelete="set null",
        ),
        sa.PrimaryKeyConstraint(
            "jurisdiction_id", name=op.f("batch_inventory_data_pkey")
        ),
    )


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