62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
"""add_citation_source_analysis_fields
|
||
|
||
Revision ID: 8ccb553ff975
|
||
Revises: 059724556401
|
||
Create Date: 2026-05-23 17:23:03.183460
|
||
|
||
"""
|
||
from typing import Sequence, Union
|
||
|
||
from alembic import op
|
||
import sqlalchemy as sa
|
||
|
||
|
||
# revision identifiers, used by Alembic.
|
||
revision: str = '8ccb553ff975'
|
||
down_revision: Union[str, Sequence[str], None] = '059724556401'
|
||
branch_labels: Union[str, Sequence[str], None] = None
|
||
depends_on: Union[str, Sequence[str], None] = None
|
||
|
||
|
||
def upgrade() -> None:
|
||
"""Upgrade schema."""
|
||
# 数据来源类型标记
|
||
op.add_column(
|
||
'citation_records',
|
||
sa.Column('data_source', sa.String(20), nullable=True,
|
||
comment='数据来源类型: ai_platform / search_engine / unknown')
|
||
)
|
||
# 提取的引用URL列表
|
||
op.add_column(
|
||
'citation_records',
|
||
sa.Column('source_urls', sa.JSON(), nullable=True,
|
||
comment='提取的引用URL列表')
|
||
)
|
||
# 提取的引用来源标题列表
|
||
op.add_column(
|
||
'citation_records',
|
||
sa.Column('source_titles', sa.JSON(), nullable=True,
|
||
comment='提取的引用来源标题列表')
|
||
)
|
||
# 引用出现的上下文片段列表
|
||
op.add_column(
|
||
'citation_records',
|
||
sa.Column('citation_contexts', sa.JSON(), nullable=True,
|
||
comment='引用出现的上下文片段列表')
|
||
)
|
||
# AI回答原始文本
|
||
op.add_column(
|
||
'citation_records',
|
||
sa.Column('ai_response_text', sa.Text(), nullable=True,
|
||
comment='AI回答原始文本(去掉data_source标记后的纯文本)')
|
||
)
|
||
|
||
|
||
def downgrade() -> None:
|
||
"""Downgrade schema."""
|
||
op.drop_column('citation_records', 'ai_response_text')
|
||
op.drop_column('citation_records', 'citation_contexts')
|
||
op.drop_column('citation_records', 'source_titles')
|
||
op.drop_column('citation_records', 'source_urls')
|
||
op.drop_column('citation_records', 'data_source')
|