"""add cascade delete for inverter

Revision ID: ed4c4bd22d6a
Revises: 3cb6ab91fdc2
Create Date: 2017-06-30 11:10:24.762958

"""

# revision identifiers, used by Alembic.
revision = 'ed4c4bd22d6a'
down_revision = '3cb6ab91fdc2'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.drop_constraint('inverters_standalone_inverter_id_fkey', 'inverters', type_='foreignkey')
    op.create_foreign_key(
        'inverters_standalone_inverter_id_fkey',
        'inverters',
        'standalone_inverters',
        ['standalone_inverter_id'],
        ['id'],
        ondelete='CASCADE'
    )


def downgrade():
    op.drop_constraint('inverters_standalone_inverter_id_fkey', 'inverters', type_='foreignkey')
    op.create_foreign_key(
        'inverters_standalone_inverter_id_fkey',
        'inverters',
        'standalone_inverters',
        ['standalone_inverter_id'],
        ['id']
    )
