38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from alembic.config import Config
|
|
from alembic.script import ScriptDirectory
|
|
|
|
|
|
def test_migration_graph_has_unique_revisions_and_one_head() -> None:
|
|
migrations = Path(__file__).parents[1] / "packages" / "harness" / "deerflow" / "persistence" / "migrations"
|
|
config = Config()
|
|
config.set_main_option("script_location", str(migrations))
|
|
scripts = ScriptDirectory.from_config(config)
|
|
|
|
revisions = list(scripts.walk_revisions())
|
|
assert len({revision.revision for revision in revisions}) == len(revisions)
|
|
assert scripts.get_heads() == ["20261020_01"]
|
|
assert scripts.get_revision("20261020_01").down_revision == (
|
|
"20261019_01",
|
|
"20261014_02",
|
|
)
|
|
assert scripts.get_revision("20261019_01").down_revision == "20261015_01"
|
|
assert scripts.get_revision("20261014_02").down_revision == "20261014_01"
|
|
assert scripts.get_revision("20261014_01").down_revision == "20261009_01"
|
|
assert scripts.get_revision("20261009_01").down_revision == "20261006_01"
|
|
|
|
assert scripts.get_revision("20260916_02").down_revision == "20260916_01"
|
|
assert scripts.get_revision("20260916_03").down_revision == (
|
|
"20260916_02",
|
|
"20260909_01",
|
|
"20260914_01",
|
|
)
|
|
assert scripts.get_revision("20260920_02").down_revision == (
|
|
"20260920_01",
|
|
"20260916_03",
|
|
)
|
|
assert scripts.get_revision("20261015_01").down_revision == "20260920_02"
|