"""sensor.generic_asset_id should not be orphaned on delete

Revision ID: e4c9cf837311
Revises: 994170c26bc6
Create Date: 2021-08-15 20:42:29.729532

"""
from alembic import op


# revision identifiers, used by Alembic.
revision = "e4c9cf837311"
down_revision = "994170c26bc6"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        "sensor_generic_asset_id_generic_asset_fkey", "sensor", type_="foreignkey"
    )
    op.create_foreign_key(
        op.f("sensor_generic_asset_id_generic_asset_fkey"),
        "sensor",
        "generic_asset",
        ["generic_asset_id"],
        ["id"],
        ondelete="CASCADE",
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("sensor_generic_asset_id_generic_asset_fkey"), "sensor", type_="foreignkey"
    )
    op.create_foreign_key(
        "sensor_generic_asset_id_generic_asset_fkey",
        "sensor",
        "generic_asset",
        ["generic_asset_id"],
        ["id"],
    )
    # ### end Alembic commands ###
