代码提交
This commit is contained in:
1 parent
f49def09ea
commit
45df500a9c
55 files changed
+3390
-461
No files matched your search
+69
@@ -0,0 +1,69 @@
|
||||
"""Persist complete position-roundtable conversation recovery snapshots.
|
||||
|
||||
Revision ID: 20260723_05
|
||||
Revises: 20260721_04
|
||||
Create Date: 2026-07-23
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
|
||||
revision = "20260723_05"
|
||||
down_revision = "20260721_04"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _has_table(table_name: str) -> bool:
|
||||
return table_name in inspect(op.get_bind()).get_table_names()
|
||||
|
||||
|
||||
def _has_column(table_name: str, column_name: str) -> bool:
|
||||
if not _has_table(table_name):
|
||||
return False
|
||||
return column_name in {
|
||||
column["name"] for column in inspect(op.get_bind()).get_columns(table_name)
|
||||
}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
long_text = LONGTEXT() if op.get_bind().dialect.name == "mysql" else sa.Text()
|
||||
session_table = "position_roundtable_sessions"
|
||||
if _has_table(session_table):
|
||||
for column in (
|
||||
"intent_conversation",
|
||||
"summary_conversation",
|
||||
"action_plan_conversation",
|
||||
):
|
||||
if not _has_column(session_table, column):
|
||||
op.add_column(
|
||||
session_table,
|
||||
sa.Column(column, long_text, nullable=True),
|
||||
)
|
||||
|
||||
node_table = "position_roundtable_nodes"
|
||||
if _has_table(node_table) and not _has_column(node_table, "conversation_snapshot"):
|
||||
op.add_column(
|
||||
node_table,
|
||||
sa.Column("conversation_snapshot", long_text, nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
node_table = "position_roundtable_nodes"
|
||||
if _has_table(node_table) and _has_column(node_table, "conversation_snapshot"):
|
||||
op.drop_column(node_table, "conversation_snapshot")
|
||||
|
||||
session_table = "position_roundtable_sessions"
|
||||
if _has_table(session_table):
|
||||
for column in (
|
||||
"action_plan_conversation",
|
||||
"summary_conversation",
|
||||
"intent_conversation",
|
||||
):
|
||||
if _has_column(session_table, column):
|
||||
op.drop_column(session_table, column)
|
||||
Reference in new issue
Block a user