chore(release): add alembic preflight check

This commit is contained in:
Xiaoxia AI
2026-06-21 13:01:49 +08:00
parent ccb6786e0b
commit e98dfc9ffb
3 changed files with 136 additions and 1 deletions
+45
View File
@@ -0,0 +1,45 @@
from scripts.alembic_preflight import AlembicPreflightResult
def test_alembic_preflight_action_for_current_version():
result = AlembicPreflightResult(
has_alembic_version=True,
business_table_count=12,
current_revision="002",
head_revision="002",
)
assert result.action == "upgrade_head_noop_or_verify"
def test_alembic_preflight_action_for_old_version():
result = AlembicPreflightResult(
has_alembic_version=True,
business_table_count=12,
current_revision="001",
head_revision="002",
)
assert result.action == "upgrade_head"
def test_alembic_preflight_action_for_existing_tables_without_version():
result = AlembicPreflightResult(
has_alembic_version=False,
business_table_count=12,
current_revision=None,
head_revision="002",
)
assert result.action == "stamp_head_then_upgrade_head"
def test_alembic_preflight_action_for_empty_database():
result = AlembicPreflightResult(
has_alembic_version=False,
business_table_count=0,
current_revision=None,
head_revision="002",
)
assert result.action == "upgrade_head_empty_database"