<filename>dataactcore/migrations/versions/2592f3bdae72_adding_cascade_to_foreign_keys_in_.py
"""Adding cascade to foreign keys in RuleSetting

Revision ID: 2592f3bdae72
Revises: 42e11ab5cea3
Create Date: 2020-02-11 17:02:00.651727

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '42e11ab5cea3'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('fk_rule', 'rule_settings', type_='foreignkey')
    op.drop_constraint('fk_impact', 'rule_settings', type_='foreignkey')
    op.create_foreign_key('fk_impact', 'rule_settings', 'rule_impact', ['impact_id'], ['rule_impact_id'], ondelete='CASCADE')
    op.create_foreign_key('fk_rule', 'rule_settings', 'rule_sql', ['rule_id'], ['rule_sql_id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade_data_broker():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('fk_rule', 'rule_settings', type_='foreignkey')
    op.drop_constraint('fk_impact', 'rule_settings', type_='foreignkey')
    op.create_foreign_key('fk_impact', 'rule_settings', 'rule_impact', ['impact_id'], ['rule_impact_id'])
    op.create_foreign_key('fk_rule', 'rule_settings', 'rule_sql', ['rule_id'], ['rule_sql_id'])
    # ### end Alembic commands ###

