Files
group_fqcd_jr/alembic/versions/20260911_advisor_goal_conversation.py
T

43 lines
1.5 KiB
Python

"""add append-only investment-goal conversation extraction records
Compatibility proof: this revision creates only the additive
``advisor_goal_conversation_extraction`` table. It does not alter, rename,
delete, reuse, or retype any baseline table or existing field.
"""
from alembic import op
revision = "20260911_adv_goal_conversation"
down_revision = "20260910_adv_quality_backtest"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute(
"""
CREATE TABLE advisor_goal_conversation_extraction (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
message_id BIGINT UNSIGNED NOT NULL,
session_id VARCHAR(64) NOT NULL,
customer_id BIGINT UNSIGNED NOT NULL,
extraction_version VARCHAR(32) NOT NULL,
extracted_fields JSON NOT NULL,
missing_fields JSON NOT NULL,
status VARCHAR(32) NOT NULL,
created_at DATETIME(6) NOT NULL,
updated_at DATETIME(6) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uk_advisor_goal_conversation_message (message_id),
KEY idx_advisor_goal_conversation_session (session_id, customer_id, id),
CONSTRAINT chk_advisor_goal_conversation_status
CHECK (status IN ('partial', 'complete', 'clarification_limit'))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
"""
)
def downgrade() -> None:
raise RuntimeError("goal conversation extraction records must not be dropped automatically")