Files
life-echo/api/alembic/versions/0007_drop_chunk_content_tsv.py
Kevin ea97427767 fix(dev): idempotent Alembic chain for squashed 0001 + clearer dev scripts
- Make migrations 0002–0008 skip schema changes already applied when
  0001_initial creates current ORM (rename segments column, timeline FK,
  memoir phase flags, drop content_tsv, eval_* tables).
- development.sh / internal-eval.sh: surface Alembic stderr, warn on
  docker-style DB hosts, TCP port checks without lsof, verify Uvicorn
  listens before claiming started.
2026-04-07 10:34:18 +08:00

39 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""移除 memory_chunks.content_tsvFTS 列已停用,检索统一向量)。
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
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)}
def upgrade() -> None:
columns = _column_names("memory_chunks")
if "content_tsv" in columns:
op.drop_column("memory_chunks", "content_tsv")
def downgrade() -> None:
columns = _column_names("memory_chunks")
if "content_tsv" not in columns:
op.add_column(
"memory_chunks",
sa.Column("content_tsv", postgresql.TSVECTOR(), nullable=True),
)