"""add control results table

Revision ID: 45c7ea136fad
Revises: 7e5d82221765
Create Date: 2024-11-13 14:14:51.387901

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel  # noqa F401


# revision identifiers, used by Alembic.
revision: str = "45c7ea136fad"
down_revision: Union[str, None] = "7e5d82221765"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "workflow_controls_results",
        sa.Column(
            "created_at",
            sa.TIMESTAMP(),
            server_default=sa.text("now()"),
            nullable=False,
        ),
        sa.Column(
            "updated_at",
            sa.TIMESTAMP(),
            server_default=sa.text("now()"),
            nullable=False,
        ),
        sa.Column("workflow_id", sa.TEXT(), nullable=False),
        sa.Column("run_id", sa.TEXT(), nullable=False),
        sa.Column("result", sa.Boolean(), nullable=False),
        sa.ForeignKeyConstraint(
            ["workflow_id"], ["workflows.workflow_id"], ondelete="CASCADE"
        ),
        sa.PrimaryKeyConstraint("workflow_id", "run_id"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("workflow_controls_results")
    # ### end Alembic commands ###
