"""cascade match deletes

Revision ID: 2e1c3b0ba3d1
Revises: 7d7fd408350c
Create Date: 2019-04-07 13:50:04.167869

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2e1c3b0ba3d1'
down_revision = '7d7fd408350c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('files_match_id_fkey1', 'files', type_='foreignkey')
    op.create_foreign_key(None, 'files', 'matches', ['match_id'], ['id'], ondelete='cascade')
    op.drop_constraint('players_match_id_fkey1', 'players', type_='foreignkey')
    op.create_foreign_key(None, 'players', 'matches', ['match_id'], ['id'], ondelete='cascade')
    op.drop_constraint('teams_match_id_fkey', 'teams', type_='foreignkey')
    op.create_foreign_key(None, 'teams', 'matches', ['match_id'], ['id'], ondelete='cascade')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'teams', type_='foreignkey')
    op.create_foreign_key('teams_match_id_fkey', 'teams', 'matches', ['match_id'], ['id'])
    op.drop_constraint(None, 'players', type_='foreignkey')
    op.create_foreign_key('players_match_id_fkey1', 'players', 'matches', ['match_id'], ['id'])
    op.drop_constraint(None, 'files', type_='foreignkey')
    op.create_foreign_key('files_match_id_fkey1', 'files', 'matches', ['match_id'], ['id'])
    # ### end Alembic commands ###
