Skip to content

Commit 560c64c

Browse files
committed
fix(alembic): collapse ingestion_run + job_metadata heads to a single tip
Two issues blocked test_no_phantom_migrations after the previous restoration: 1. e728126476a8 (add kb_id to ingestion_run) chained off 15fe9304bca7 (creates knowledge_base) which left the ingestion_run-creation migration 72df732be86b dangling as its own head. Re-chain e728126476a8 onto 72df732be86b so the ingestion_run chain is linear; the FK target dependency on knowledge_base is declared via depends_on instead of down_revision. 2. After step 1 the graph still had two independent tips — 16a290ab1332 (ingestion_run.user_metadata) and da7f6b9b638a (job.job_metadata) — neither referencing the other. Add an empty merge migration 5238aab36810 unifying both so 'alembic upgrade head' resolves to a single revision. `alembic heads` now reports ['5238aab36810'] and test_migration_execution passes locally (8 passed, 2 sqlite-only skips).
1 parent b71e97f commit 560c64c

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Merge ingestion_run.user_metadata and job.job_metadata heads.
2+
3+
Revision ID: 5238aab36810
4+
Revises: 16a290ab1332, da7f6b9b638a
5+
Create Date: 2026-04-30 20:30:00.000000
6+
7+
Phase: MERGE
8+
Safe to rollback: YES — merge migrations are pure graph nodes; they
9+
don't run any DDL.
10+
11+
After the kb_id-on-ingestion_run change (``e728126476a8``) was rebased
12+
onto ``72df732be86b`` so the ``ingestion_run`` chain is linear, the
13+
graph still had two independent tips:
14+
15+
* ``16a290ab1332`` — adds ``user_metadata`` JSON to ``ingestion_run``.
16+
* ``da7f6b9b638a`` — adds ``job_metadata`` JSON to ``job``.
17+
18+
Neither references the other, so ``alembic upgrade head`` would
19+
``CommandError: Multiple head revisions are present``. This empty
20+
migration unifies them so future migrations can chain off a single
21+
head without picking sides between the KB ingestion-run and the
22+
job-metadata work.
23+
"""
24+
25+
from collections.abc import Sequence
26+
27+
# revision identifiers, used by Alembic.
28+
revision: str = "5238aab36810" # pragma: allowlist secret
29+
down_revision: tuple[str, ...] | str | None = (
30+
"16a290ab1332", # pragma: allowlist secret
31+
"da7f6b9b638a", # pragma: allowlist secret
32+
)
33+
branch_labels: str | Sequence[str] | None = None
34+
depends_on: str | Sequence[str] | None = None
35+
36+
37+
def upgrade() -> None:
38+
"""No-op merge — combines two parallel migration heads."""
39+
40+
41+
def downgrade() -> None:
42+
"""No-op merge — combines two parallel migration heads."""

src/backend/base/langflow/alembic/versions/e728126476a8_add_kb_id_to_ingestion_run.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@
2222

2323
# revision identifiers, used by Alembic.
2424
revision: str = "e728126476a8" # pragma: allowlist secret
25-
down_revision: str | None = "15fe9304bca7" # pragma: allowlist secret
25+
# Chain through ``72df732be86b`` (creates ingestion_run) so this
26+
# migration has only one parent path. The FK target ``knowledge_base``
27+
# table is a separate dependency declared via ``depends_on`` so the
28+
# graph stays valid no matter which order the unrelated KB-table
29+
# branch runs.
30+
down_revision: str | None = "72df732be86b" # pragma: allowlist secret
2631
branch_labels: str | Sequence[str] | None = None
27-
depends_on: str | Sequence[str] | None = None
32+
depends_on: str | Sequence[str] | None = "15fe9304bca7" # pragma: allowlist secret
2833

2934
TABLE_NAME = "ingestion_run"
3035
COLUMN_NAME = "kb_id"

0 commit comments

Comments
 (0)