"""Unique constraints, contract metadata

Revision ID: 3f2ec6253b7e
Revises: 04e9f9125c90
Create Date: 2022-04-26 04:53:05.221128

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "3f2ec6253b7e"
down_revision = "04e9f9125c90"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(
        op.f("uq_dropper_claimants_dropper_claim_id"),
        "dropper_claimants",
        ["dropper_claim_id", "address"],
    )
    op.create_unique_constraint(
        op.f("uq_dropper_claimants_id"), "dropper_claimants", ["id"]
    )
    op.alter_column(
        "dropper_claims",
        "terminus_address",
        existing_type=sa.VARCHAR(length=256),
        nullable=True,
    )
    op.alter_column(
        "dropper_claims", "terminus_pool_id", existing_type=sa.BIGINT(), nullable=True
    )
    op.create_unique_constraint(op.f("uq_dropper_claims_id"), "dropper_claims", ["id"])
    op.add_column(
        "dropper_contracts", sa.Column("title", sa.VARCHAR(length=128), nullable=True)
    )
    op.add_column(
        "dropper_contracts", sa.Column("description", sa.String(), nullable=True)
    )
    op.add_column(
        "dropper_contracts", sa.Column("image_uri", sa.String(), nullable=True)
    )
    op.create_unique_constraint(
        op.f("uq_dropper_contracts_id"), "dropper_contracts", ["id"]
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("uq_dropper_contracts_id"), "dropper_contracts", type_="unique"
    )
    op.drop_column("dropper_contracts", "image_uri")
    op.drop_column("dropper_contracts", "description")
    op.drop_column("dropper_contracts", "title")
    op.drop_constraint(op.f("uq_dropper_claims_id"), "dropper_claims", type_="unique")
    op.alter_column(
        "dropper_claims", "terminus_pool_id", existing_type=sa.BIGINT(), nullable=False
    )
    op.alter_column(
        "dropper_claims",
        "terminus_address",
        existing_type=sa.VARCHAR(length=256),
        nullable=False,
    )
    op.drop_constraint(
        op.f("uq_dropper_claimants_id"), "dropper_claimants", type_="unique"
    )
    op.drop_constraint(
        op.f("uq_dropper_claimants_dropper_claim_id"),
        "dropper_claimants",
        type_="unique",
    )
    # ### end Alembic commands ###
