Esempio n. 1
0
def prune(
    revision: str = typer.Argument(
        ...,
        help="The revision hash to be moved",
    ),
    alembic_home_dir: pathlib.Path = typer.Option(
        "etc/alembic/versions",
        exists=True,
        help="The directory where the alembic migrations live",
    ),
):
    home = MigrationHome(alembic_home_dir)
    home.prune(revision)
Esempio n. 2
0
 def test_prune__delete_head(self, scripts_dir):
     home = MigrationHome(scripts_dir)
     assert scripts_dir.joinpath("gggggg-dummy-migration.py").exists()
     home.prune("gggggg")
     assert home.generate_dependency_graph() == {
         "aaaaaa": {None},
         "bbbbbb": {"aaaaaa"},
         "cccccc": {"bbbbbb"},
         "dddddd": {"bbbbbb"},
         "eeeeee": {"cccccc", "dddddd"},
         "ffffff": {"dddddd"},
     }
     assert not scripts_dir.joinpath("gggggg-dummy-migration.py").exists()
Esempio n. 3
0
 def test_prune__delete_complex_branch(self, scripts_dir):
     home = MigrationHome(scripts_dir)
     assert os.path.exists(
         os.path.join(scripts_dir, "dddddd-dummy-migration.py"))
     home.prune("dddddd")
     assert home.generate_dependency_graph() == {
         "aaaaaa": {None},
         "bbbbbb": {"aaaaaa"},
         "cccccc": {"bbbbbb"},
         "eeeeee": {"bbbbbb", "cccccc"},
         "ffffff": {"bbbbbb"},
         "gggggg": {"eeeeee", "ffffff"},
     }
     assert not os.path.exists(
         os.path.join(scripts_dir, "dddddd-dummy-migration.py"))
Esempio n. 4
0
 def test_heads(self, scripts_dir):
     home = MigrationHome(scripts_dir)
     assert home.heads() == {"gggggg"}
     home.prune("gggggg")
     assert home.heads() == {"eeeeee", "ffffff"}