43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""add_missing_sentiment_fields
|
|
|
|
Revision ID: 059724556401
|
|
Revises: a7b9c1d3ef67
|
|
Create Date: 2026-05-23 17:19:50.789398
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '059724556401'
|
|
down_revision: Union[str, Sequence[str], None] = 'a7b9c1d3ef67'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# 添加情感分析字段到 citation_records 表
|
|
op.add_column('citation_records',
|
|
sa.Column('sentiment', sa.String(20), nullable=True,
|
|
comment='情感倾向: positive / neutral / negative')
|
|
)
|
|
op.add_column('citation_records',
|
|
sa.Column('sentiment_confidence', sa.Float(), nullable=True,
|
|
comment='情感分析置信度 0.0-1.0')
|
|
)
|
|
op.add_column('citation_records',
|
|
sa.Column('sentiment_key_phrases', sa.JSON(), nullable=True,
|
|
comment='关键情感短语列表')
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
op.drop_column('citation_records', 'sentiment_key_phrases')
|
|
op.drop_column('citation_records', 'sentiment_confidence')
|
|
op.drop_column('citation_records', 'sentiment')
|