"""Set null cascade on user.current_poll

Revision ID: 7fe81a5d2f88
Revises: dd18721adbcc
Create Date: 2019-06-16 06:10:29.554939

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "7fe81a5d2f88"
down_revision = "dd18721adbcc"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("user_current_poll_id_fkey", "user", type_="foreignkey")
    op.create_foreign_key(
        None, "user", "poll", ["current_poll_id"], ["id"], ondelete="set null"
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "user", type_="foreignkey")
    op.create_foreign_key(
        "user_current_poll_id_fkey",
        "user",
        "poll",
        ["current_poll_id"],
        ["id"],
        ondelete="CASCADE",
    )
    # ### end Alembic commands ###
