"""add agents and activity events Revision ID: a1b2c3d4e5f6 Revises: 9c4f1a2b3d4e Create Date: 2026-02-03 23:50:00.000000 """ from __future__ import annotations from alembic import op import sqlalchemy as sa import sqlmodel # revision identifiers, used by Alembic. revision = "a1b2c3d4e5f6" down_revision = "9c4f1a2b3d4e" branch_labels = None depends_on = None def upgrade() -> None: op.create_table( "agents", sa.Column("id", sa.Uuid(), nullable=False), sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False), sa.Column("status", sqlmodel.sql.sqltypes.AutoString(), nullable=False), sa.Column("last_seen_at", sa.DateTime(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.Column("updated_at", sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint("id"), ) op.create_index(op.f("ix_agents_name"), "agents", ["name"], unique=False) op.create_index(op.f("ix_agents_status"), "agents", ["status"], unique=False) op.create_table( "activity_events", sa.Column("id", sa.Uuid(), nullable=False), sa.Column("event_type", sqlmodel.sql.sqltypes.AutoString(), nullable=False), sa.Column("message", sqlmodel.sql.sqltypes.AutoString(), nullable=True), sa.Column("agent_id", sa.Uuid(), nullable=True), sa.Column("task_id", sa.Uuid(), nullable=True), sa.Column("created_at", sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(["agent_id"], ["agents.id"]), sa.ForeignKeyConstraint(["task_id"], ["tasks.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_activity_events_agent_id"), "activity_events", ["agent_id"], unique=False ) op.create_index( op.f("ix_activity_events_event_type"), "activity_events", ["event_type"], unique=False, ) op.create_index( op.f("ix_activity_events_task_id"), "activity_events", ["task_id"], unique=False ) def downgrade() -> None: op.drop_index(op.f("ix_activity_events_task_id"), table_name="activity_events") op.drop_index(op.f("ix_activity_events_event_type"), table_name="activity_events") op.drop_index(op.f("ix_activity_events_agent_id"), table_name="activity_events") op.drop_table("activity_events") op.drop_index(op.f("ix_agents_status"), table_name="agents") op.drop_index(op.f("ix_agents_name"), table_name="agents") op.drop_table("agents")