- 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.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""移除 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
|
||
|
||
|
||
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),
|
||
)
|