"""add cascade deletes for shelter foreign keys

Revision ID: 9739a302f92b
Revises: 84f41dba40eb
Create Date: 2019-01-07 13:40:46.569048

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9739a302f92b'
down_revision = '84f41dba40eb'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('counts_shelter_id_fkey', 'counts', type_='foreignkey')
    op.create_foreign_key(None, 'counts', 'shelters', ['shelter_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint('logs_shelter_id_fkey', 'logs', type_='foreignkey')
    op.create_foreign_key(None, 'logs', 'shelters', ['shelter_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'logs', type_='foreignkey')
    op.create_foreign_key('logs_shelter_id_fkey', 'logs', 'shelters', ['shelter_id'], ['id'])
    op.drop_constraint(None, 'counts', type_='foreignkey')
    op.create_foreign_key('counts_shelter_id_fkey', 'counts', 'shelters', ['shelter_id'], ['id'])
    # ### end Alembic commands ###
