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:
@@ -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),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user