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.
This commit is contained in:
Kevin
2026-04-07 10:34:09 +08:00
parent 29dec8fe32
commit ea97427767
7 changed files with 661 additions and 274 deletions

View File

@@ -17,12 +17,22 @@ 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:
op.drop_column("memory_chunks", "content_tsv")
columns = _column_names("memory_chunks")
if "content_tsv" in columns:
op.drop_column("memory_chunks", "content_tsv")
def downgrade() -> None:
op.add_column(
"memory_chunks",
sa.Column("content_tsv", postgresql.TSVECTOR(), nullable=True),
)
columns = _column_names("memory_chunks")
if "content_tsv" not in columns:
op.add_column(
"memory_chunks",
sa.Column("content_tsv", postgresql.TSVECTOR(), nullable=True),
)