"""add tools model Revision ID: ebc80cea7965 Revises: 36b5dbf670e4 Create Date: 2026-01-01 10:13:50.807135 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = "ebc80cea7965" down_revision: Union[str, None] = "36b5dbf670e4" 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! ### sa.Enum("active", "archived", "draft", name="tool_status").create(op.get_bind()) sa.Enum("http_api", "native", "integration", name="tool_category").create( op.get_bind() ) op.create_table( "tools", sa.Column("id", sa.Integer(), nullable=False), sa.Column("tool_uuid", sa.String(length=36), nullable=False), sa.Column("organization_id", sa.Integer(), nullable=False), sa.Column("name", sa.String(length=255), nullable=False), sa.Column("description", sa.String(), nullable=True), sa.Column( "category", postgresql.ENUM( "http_api", "native", "integration", name="tool_category", create_type=False, ), nullable=False, ), sa.Column("icon", sa.String(length=50), nullable=True), sa.Column("icon_color", sa.String(length=7), nullable=True), sa.Column( "status", postgresql.ENUM( "active", "archived", "draft", name="tool_status", create_type=False ), server_default=sa.text("'active'::tool_status"), nullable=False, ), sa.Column("definition", sa.JSON(), nullable=False), sa.Column("created_by", sa.Integer(), nullable=False), sa.Column("created_at", sa.DateTime(timezone=True), nullable=True), sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint( ["created_by"], ["users.id"], ), sa.ForeignKeyConstraint( ["organization_id"], ["organizations.id"], ondelete="CASCADE" ), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("organization_id", "name", name="unique_org_tool_name"), ) op.create_index("ix_tools_category", "tools", ["category"], unique=False) op.create_index( "ix_tools_organization_id", "tools", ["organization_id"], unique=False ) op.create_index("ix_tools_status", "tools", ["status"], unique=False) op.create_index(op.f("ix_tools_tool_uuid"), "tools", ["tool_uuid"], unique=True) op.create_index("ix_tools_uuid", "tools", ["tool_uuid"], unique=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index("ix_tools_uuid", table_name="tools") op.drop_index(op.f("ix_tools_tool_uuid"), table_name="tools") op.drop_index("ix_tools_status", table_name="tools") op.drop_index("ix_tools_organization_id", table_name="tools") op.drop_index("ix_tools_category", table_name="tools") op.drop_table("tools") sa.Enum("http_api", "native", "integration", name="tool_category").drop( op.get_bind() ) sa.Enum("active", "archived", "draft", name="tool_status").drop(op.get_bind()) # ### end Alembic commands ###