76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
"""add post-call analysis configuration and results
|
|
|
|
Revision ID: 20260807_0013
|
|
Revises: 20260804_0012
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
revision: str = "20260807_0013"
|
|
down_revision: str | Sequence[str] | None = "20260804_0012"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column(
|
|
"assistants",
|
|
sa.Column(
|
|
"analysis_config",
|
|
postgresql.JSONB(astext_type=sa.Text()),
|
|
nullable=False,
|
|
server_default=sa.text("'{}'::jsonb"),
|
|
),
|
|
)
|
|
op.add_column(
|
|
"conversation_sessions",
|
|
sa.Column(
|
|
"analysis_status",
|
|
sa.String(length=16),
|
|
nullable=False,
|
|
server_default="none",
|
|
),
|
|
)
|
|
op.add_column(
|
|
"conversation_sessions",
|
|
sa.Column(
|
|
"analysis_data",
|
|
postgresql.JSONB(astext_type=sa.Text()),
|
|
nullable=False,
|
|
server_default=sa.text("'{}'::jsonb"),
|
|
),
|
|
)
|
|
op.add_column(
|
|
"conversation_sessions",
|
|
sa.Column(
|
|
"analysis_error",
|
|
sa.String(length=2048),
|
|
nullable=False,
|
|
server_default="",
|
|
),
|
|
)
|
|
op.create_index(
|
|
"ix_conversation_sessions_analysis_status",
|
|
"conversation_sessions",
|
|
["analysis_status"],
|
|
unique=False,
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(
|
|
"ix_conversation_sessions_analysis_status",
|
|
table_name="conversation_sessions",
|
|
)
|
|
op.drop_column("conversation_sessions", "analysis_error")
|
|
op.drop_column("conversation_sessions", "analysis_data")
|
|
op.drop_column("conversation_sessions", "analysis_status")
|
|
op.drop_column("assistants", "analysis_config")
|