"""Pipeline run replays [bf4203afb657].

Revision ID: bf4203afb657
Revises: b949c5d1bc0d
Create Date: 2026-02-02 14:17:42.255690

"""

import sqlalchemy as sa
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision = "bf4203afb657"
down_revision = "b949c5d1bc0d"
branch_labels = None
depends_on = None


def upgrade() -> None:
    """Upgrade database schema and/or data, creating a new revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("pipeline_run", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "original_run_id", sqlmodel.sql.sqltypes.GUID(), nullable=True
            )
        )
        batch_op.create_foreign_key(
            "fk_pipeline_run_original_run_id_pipeline_run",
            "pipeline_run",
            ["original_run_id"],
            ["id"],
            ondelete="SET NULL",
        )

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade database schema and/or data back to the previous revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("pipeline_run", schema=None) as batch_op:
        batch_op.drop_constraint(
            "fk_pipeline_run_original_run_id_pipeline_run", type_="foreignkey"
        )
        batch_op.drop_column("original_run_id")

    # ### end Alembic commands ###
