mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-16 08:25:18 +02:00
* chore: remove looptalk Remove looptalk in the current version. We will be rethinking looptalk in a fresh way. * chore: formatting fix
204 lines
6.5 KiB
Python
204 lines
6.5 KiB
Python
"""drop_looptalk_tables
|
|
|
|
Revision ID: 4c1f1e3e8ef2
|
|
Revises: 6499c608d0f6
|
|
Create Date: 2026-05-16 14:46:18.296517
|
|
|
|
"""
|
|
|
|
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 = "4c1f1e3e8ef2"
|
|
down_revision: Union[str, None] = "6499c608d0f6"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Drop child table first so its FK to looptalk_test_sessions is removed before the parent is dropped.
|
|
op.drop_index(
|
|
op.f("ix_looptalk_conversations_session_id"),
|
|
table_name="looptalk_conversations",
|
|
)
|
|
op.drop_table("looptalk_conversations")
|
|
op.drop_index(
|
|
op.f("ix_looptalk_test_sessions_group_id"), table_name="looptalk_test_sessions"
|
|
)
|
|
op.drop_index(
|
|
op.f("ix_looptalk_test_sessions_load_test_group_id"),
|
|
table_name="looptalk_test_sessions",
|
|
)
|
|
op.drop_index(
|
|
op.f("ix_looptalk_test_sessions_org_id"), table_name="looptalk_test_sessions"
|
|
)
|
|
op.drop_index(
|
|
op.f("ix_looptalk_test_sessions_status"), table_name="looptalk_test_sessions"
|
|
)
|
|
op.drop_table("looptalk_test_sessions")
|
|
sa.Enum(
|
|
"pending", "running", "completed", "failed", name="test_session_status"
|
|
).drop(op.get_bind())
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
sa.Enum(
|
|
"pending", "running", "completed", "failed", name="test_session_status"
|
|
).create(op.get_bind())
|
|
op.create_table(
|
|
"looptalk_conversations",
|
|
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column("test_session_id", sa.INTEGER(), autoincrement=False, nullable=False),
|
|
sa.Column("duration_seconds", sa.INTEGER(), autoincrement=False, nullable=True),
|
|
sa.Column(
|
|
"actor_recording_url", sa.VARCHAR(), autoincrement=False, nullable=True
|
|
),
|
|
sa.Column(
|
|
"adversary_recording_url", sa.VARCHAR(), autoincrement=False, nullable=True
|
|
),
|
|
sa.Column(
|
|
"combined_recording_url", sa.VARCHAR(), autoincrement=False, nullable=True
|
|
),
|
|
sa.Column(
|
|
"transcript",
|
|
postgresql.JSON(astext_type=sa.Text()),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"metrics",
|
|
postgresql.JSON(astext_type=sa.Text()),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"created_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.Column(
|
|
"ended_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["test_session_id"],
|
|
["looptalk_test_sessions.id"],
|
|
name=op.f("looptalk_conversations_test_session_id_fkey"),
|
|
),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("looptalk_conversations_pkey")),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_looptalk_conversations_session_id"),
|
|
"looptalk_conversations",
|
|
["test_session_id"],
|
|
unique=False,
|
|
)
|
|
op.create_table(
|
|
"looptalk_test_sessions",
|
|
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column("organization_id", sa.INTEGER(), autoincrement=False, nullable=False),
|
|
sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=False),
|
|
sa.Column(
|
|
"status",
|
|
postgresql.ENUM(
|
|
"pending",
|
|
"running",
|
|
"completed",
|
|
"failed",
|
|
name="test_session_status",
|
|
create_type=False,
|
|
),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"actor_workflow_id", sa.INTEGER(), autoincrement=False, nullable=False
|
|
),
|
|
sa.Column(
|
|
"adversary_workflow_id", sa.INTEGER(), autoincrement=False, nullable=False
|
|
),
|
|
sa.Column(
|
|
"load_test_group_id", sa.VARCHAR(), autoincrement=False, nullable=True
|
|
),
|
|
sa.Column("test_index", sa.INTEGER(), autoincrement=False, nullable=True),
|
|
sa.Column(
|
|
"config",
|
|
postgresql.JSON(astext_type=sa.Text()),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"results",
|
|
postgresql.JSON(astext_type=sa.Text()),
|
|
autoincrement=False,
|
|
nullable=False,
|
|
),
|
|
sa.Column("error", sa.VARCHAR(), autoincrement=False, nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.Column(
|
|
"started_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.Column(
|
|
"completed_at",
|
|
postgresql.TIMESTAMP(timezone=True),
|
|
autoincrement=False,
|
|
nullable=True,
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["actor_workflow_id"],
|
|
["workflows.id"],
|
|
name=op.f("looptalk_test_sessions_actor_workflow_id_fkey"),
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["adversary_workflow_id"],
|
|
["workflows.id"],
|
|
name=op.f("looptalk_test_sessions_adversary_workflow_id_fkey"),
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["organization_id"],
|
|
["organizations.id"],
|
|
name=op.f("looptalk_test_sessions_organization_id_fkey"),
|
|
),
|
|
sa.PrimaryKeyConstraint("id", name=op.f("looptalk_test_sessions_pkey")),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_looptalk_test_sessions_status"),
|
|
"looptalk_test_sessions",
|
|
["status"],
|
|
unique=False,
|
|
)
|
|
op.create_index(
|
|
op.f("ix_looptalk_test_sessions_org_id"),
|
|
"looptalk_test_sessions",
|
|
["organization_id"],
|
|
unique=False,
|
|
)
|
|
op.create_index(
|
|
op.f("ix_looptalk_test_sessions_load_test_group_id"),
|
|
"looptalk_test_sessions",
|
|
["load_test_group_id"],
|
|
unique=False,
|
|
)
|
|
op.create_index(
|
|
op.f("ix_looptalk_test_sessions_group_id"),
|
|
"looptalk_test_sessions",
|
|
["load_test_group_id"],
|
|
unique=False,
|
|
)
|
|
# ### end Alembic commands ###
|