Skip to content

fix(migrations): break Alembic duplicate-revision 172 head (renumber soft-delete to 173) - #581

Merged
hieptl merged 1 commit into
mainfrom
fix/alembic-duplicate-172-head
Sep 30, 2026
Merged

hieptl merged 1 commit into
mainfrom
fix/alembic-duplicate-172-head

Conversation

@aivong-openhands

@aivong-openhands aivong-openhands commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

main currently has two Alembic migrations claiming the same revision 172:

Both point at 171 and neither is a child of the other, so the history has two heads. alembic upgrade head fails with:

Multiple head revisions are present for given argument 'head'; please specify a
specific target revision, '<branchname>@head' to narrow to a specific head, or
'heads' for all heads

This breaks the Postgres test-DB template build (alembic upgrade head at INTERNALERROR before any test runs) and would break a real migration run on deploy. #555 fixed exactly this class of collision on 09-28; the soft-delete migration merged on 09-29 reintroduced it.

What

  • Renumber the newer soft-delete migration to 173 and chain it after 172 (the deepseek repair): revision = '173', down_revision = '172'. File renamed 172_… → 173_soft_delete_conversations.py.
  • Fix that migration's stale docstring header, which still read Revision ID: 171 / Revises: 170.

The two migrations are independent (soft-delete adds a deleted_at column + partial index; the deepseek migration is a settings/data repair), so ordering them 172 → 173 is behaviour-preserving.

How tested

  • alembic upgrade head now resolves to a single linear head (170 → 171 → 172 → 173); no duplicate revision ids remain.
  • The Postgres test-DB template build (which runs alembic upgrade head) now succeeds, and tests/unit/app_server/test_webhook_router_stats.py::TestProcessStatsEvent passes — previously it aborted with INTERNALERROR ... Multiple head revisions are present.
  • ruff format --check / ruff check clean on the renamed file.

Note for reviewers

Open PR #453 adds 173_unset_empty_agent_profile_tools.py with down_revision = '172'. Once this lands, #453 will collide on 173 and should be rebased to down_revision = '173' / revision 174.

Type

  • Bug fix

This PR was created by an AI agent (OpenHands) on behalf of @aivong-openhands.


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-7ad296a

…te-revision 172 head

Both 172_repair_deepseek_default_self_hosted.py and
172_soft_delete_conversations.py declared revision '172' with
down_revision '171', leaving two Alembic heads. 'alembic upgrade head'
fails with 'Multiple head revisions are present', which breaks the test
DB template build and any fresh migration run.

Renumber the newer soft-delete migration to 173 and chain it after 172
(the deepseek repair), restoring a single linear head. Also corrects the
migration's stale docstring header (Revision ID/Revises).

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: fix A bug fix label Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains migrations. Please synchronize before merging to prevent conflicts.

@aivong-openhands
aivong-openhands marked this pull request as ready for review September 30, 2026 03:37
@aivong-openhands
aivong-openhands enabled auto-merge (squash) September 30, 2026 03:37
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  migrations/versions
  173_soft_delete_conversations.py
Project Total  

This report was generated by python-coverage-comment-action

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏

@hieptl
hieptl disabled auto-merge September 30, 2026 05:50
@hieptl
hieptl merged commit 85e5f23 into main Sep 30, 2026
42 checks passed
@hieptl
hieptl deleted the fix/alembic-duplicate-172-head branch September 30, 2026 05:50
@openhands-release-bot openhands-release-bot Bot added the released: 1.68.0 Shipped in 1.68.0 label Oct 2, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.68.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.68.0 Shipped in 1.68.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants