Pipeline/backend/migrations/versions/a1b2c3d4e5f5_add_board_webh...

71 lines
2.0 KiB
Python

"""Add board_webhooks table.
Revision ID: a1b2c3d4e5f5
Revises: 658dca8f4a11
Create Date: 2026-03-03 00:00:00.000000
"""
from __future__ import annotations
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision = "a1b2c3d4e5f5"
down_revision = "4c1f5e2a7b9d"
branch_labels = None
depends_on = None
def upgrade() -> None:
"""Create board_webhooks table."""
op.create_table(
"board_webhooks",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("board_id", sa.Uuid(), nullable=False),
sa.Column("agent_id", sa.Uuid(), nullable=True),
sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("enabled", sa.Boolean(), nullable=False),
sa.Column("secret", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("signature_header", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(
["board_id"],
["boards.id"],
),
sa.ForeignKeyConstraint(
["agent_id"],
["agents.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_board_webhooks_board_id"),
"board_webhooks",
["board_id"],
unique=False,
)
op.create_index(
op.f("ix_board_webhooks_agent_id"),
"board_webhooks",
["agent_id"],
unique=False,
)
op.create_index(
op.f("ix_board_webhooks_enabled"),
"board_webhooks",
["enabled"],
unique=False,
)
def downgrade() -> None:
"""Drop board_webhooks table."""
op.drop_index(op.f("ix_board_webhooks_enabled"), table_name="board_webhooks")
op.drop_index(op.f("ix_board_webhooks_agent_id"), table_name="board_webhooks")
op.drop_index(op.f("ix_board_webhooks_board_id"), table_name="board_webhooks")
op.drop_table("board_webhooks")