"""v0.14.9.

Revision ID: 799ed4dbb42f
Revises: 8c5253e809e7
Create Date: 2023-10-06 15:41:16.592578

"""
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "799ed4dbb42f"
down_revision = "8c5253e809e7"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "cloud_run_instance",
        "lamin_instance_id",
        existing_type=postgresql.UUID(),
        nullable=True,
    )
    op.drop_constraint(
        "fk_cloud_run_instance_lamin_instance_id_instance",
        "cloud_run_instance",
        type_="foreignkey",
    )
    op.create_foreign_key(
        op.f("fk_cloud_run_instance_lamin_instance_id_instance"),
        "cloud_run_instance",
        "instance",
        ["lamin_instance_id"],
        ["id"],
        ondelete="CASCADE",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("fk_cloud_run_instance_lamin_instance_id_instance"),
        "cloud_run_instance",
        type_="foreignkey",
    )
    op.create_foreign_key(
        "fk_cloud_run_instance_lamin_instance_id_instance",
        "cloud_run_instance",
        "instance",
        ["lamin_instance_id"],
        ["id"],
    )
    op.alter_column(
        "cloud_run_instance",
        "lamin_instance_id",
        existing_type=postgresql.UUID(),
        nullable=False,
    )
    # ### end Alembic commands ###
