SEP-1813: A stripped app whose versions/ directory survives still fails alembic --name sep upgrade heads - #1379
SEP-1813: A stripped app whose versions/ directory survives still fails alembic --name sep upgrade heads#1379peter-o-addo wants to merge 12 commits into
versions/ directory survives still fails alembic --name sep upgrade heads#1379Conversation
There was a problem hiding this comment.
Pull request overview
Broadens orphan-head detection to handle stripped apps whose migration directories remain but contain no revisions.
Changes:
- Detect empty as well as absent migration locations.
- Align generated configuration and CLI diagnostics.
- Add unit, integration, and generator-to-filter handoff coverage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
app/sep/migrations/_orphan_heads.py |
Detects locations contributing no revisions. |
scripts/sync_alembic_version_locations.py |
Updates synchronization guidance and diagnostics. |
alembic.ini |
Regenerates the explanatory header. |
tests/app/sep/migrations/test_orphan_heads.py |
Tests empty-location detection. |
tests/app/sep/migrations/test_alembic_integration.py |
Tests upgrades with empty migration directories. |
tests/app/sep/migrations/test_strip_handoff.py |
Covers generator/filter handoff scenarios. |
tests/scripts/test_sync_alembic_version_locations.py |
Tests synchronization refusal behavior. |
Suppressed comments (8)
tests/app/sep/migrations/test_alembic_integration.py:492
AC5is an unreachable ticket reference in the shipped test. Keep the docstring self-contained by stating only the behavior it verifies.
"""Name the empty versions/ location in the skip WARNING (AC5)."""
tests/app/sep/migrations/test_strip_handoff.py:103
- Pin UTF-8 for the synthetic Alembic configuration so this integration test has deterministic file I/O across hosts.
ini_path.write_text(
"[alembic]\n"
"databases = sep\n"
"\n"
"[sep]\n"
"script_location = %(here)s/app/sep/migrations\n"
"version_path_separator = :\n"
f"version_locations = {_MAIN_ENTRY}:"
f"{_ALPHA_ENTRY}\n"
)
tests/app/sep/migrations/test_strip_handoff.py:90
- Pin UTF-8 rather than relying on the host locale for this text file.
(alpha / "__init__.py").write_text("")
tests/app/sep/migrations/test_strip_handoff.py:157
- Pin UTF-8 on this text read rather than relying on the test runner’s locale.
before = ini_path.read_text()
tests/app/sep/migrations/test_strip_handoff.py:165
- Both text reads should pin UTF-8 so the assertions use the same deterministic encoding as the writer.
assert ini_path.read_text() == before
else:
assert _ALPHA_ENTRY in ini_path.read_text()
tests/scripts/test_sync_alembic_version_locations.py:473
- Pin UTF-8 on the newly added text read instead of inheriting the host locale.
assert ini_path.read_text() == before
tests/scripts/test_sync_alembic_version_locations.py:481
- Pin UTF-8 on the newly added text read instead of inheriting the host locale.
assert "app/sep/apps/alpha/migrations/versions" in ini_path.read_text()
tests/scripts/test_sync_alembic_version_locations.py:528
- Pin UTF-8 on the newly added text read instead of inheriting the host locale.
assert ini_path.read_text() == before
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1. Claim text2. Sync refusal on stripped treeRan the sync script against a temp ini that still lists Output: 3. Empty versions dir arms the filterCalled Output: 4. Populated tree stays fail-closedCalled Output: |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
Summary
Widen the orphan-head filter so stripped apps with empty or leftover versions/ dirs still migrate, and align the sync-script advice with that rule.
_orphan_heads.py: replacemissing_version_locationswithempty_version_locations, and update fail-closed docs / ERROR / WARNINGsync_alembic_version_locations.py,alembic.ini: update GENERATED_COMMENT and refusal stderr, then regenerate the committed headerTested
scripts/sync_alembic_version_locations.pyandalembic.iniboth say a configured location that is absent from disk or contributes no migration scripts arms the filter.contributes no migration scriptsandupgrade heads.empty_version_locationswith a present-but-empty versions dir and confirm that path is reported (filter arms).empty_version_locationson the real populatedalembic.initree and confirm it returns empty (fail-closed evidence stays off).Checklist
make test)make run-pre-commit)make makemigrations)changelog.d/if the change is user-facing (make changelog-add), or confirmed N/A (internal-only change, or a same-release-cycle fix for an unreleased sibling ticket)