2026-04-03 11:43:16 +08:00
|
|
|
|
"""移除 memory_chunks.content_tsv(FTS 列已停用,检索统一向量)。
|
|
|
|
|
|
|
|
|
|
|
|
Revision ID: 0007_drop_chunk_content_tsv
|
|
|
|
|
|
Revises: 0006_segment_memoir_phases
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from typing import Sequence, Union
|
|
|
|
|
|
|
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
|
|
|
|
|
|
|
|
revision: str = "0007_drop_chunk_content_tsv"
|
|
|
|
|
|
down_revision: Union[str, None] = "0006_segment_memoir_phases"
|
|
|
|
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-07 10:34:09 +08:00
|
|
|
|
def _column_names(table_name: str) -> set[str]:
|
|
|
|
|
|
bind = op.get_bind()
|
|
|
|
|
|
inspector = sa.inspect(bind)
|
|
|
|
|
|
return {column["name"] for column in inspector.get_columns(table_name)}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-03 11:43:16 +08:00
|
|
|
|
def upgrade() -> None:
|
2026-04-07 10:34:09 +08:00
|
|
|
|
columns = _column_names("memory_chunks")
|
|
|
|
|
|
if "content_tsv" in columns:
|
|
|
|
|
|
op.drop_column("memory_chunks", "content_tsv")
|
2026-04-03 11:43:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
2026-04-07 10:34:09 +08:00
|
|
|
|
columns = _column_names("memory_chunks")
|
|
|
|
|
|
if "content_tsv" not in columns:
|
|
|
|
|
|
op.add_column(
|
|
|
|
|
|
"memory_chunks",
|
|
|
|
|
|
sa.Column("content_tsv", postgresql.TSVECTOR(), nullable=True),
|
|
|
|
|
|
)
|