def test_rebase__normal_rebase(self, scripts_dir): home = MigrationHome(scripts_dir) home.migrations["gggggg"].change_down_revision("cccccc") home.migrations["eeeeee"].change_down_revision("dddddd") # now, the graph should look like this: # ....................... # . . # . aaaaaa . # . | . # . bbbbbb . # . / \ . # . / \ . # . ccccc dddddd . # . | / \ . # . | / \ . # . | eeeee ffffff . # . | . # . gggggg . # . . # . . # ....................... home.rebase("dddddd", "gggggg") assert home.generate_dependency_graph() == { "aaaaaa": {None}, "bbbbbb": {"aaaaaa"}, "cccccc": {"bbbbbb"}, "dddddd": {"gggggg"}, "eeeeee": {"dddddd"}, "ffffff": {"dddddd"}, "gggggg": {"cccccc"}, }
def rebase( 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", ), new_bases: typing.List[str] = typer.Argument( ..., help="The new base(s) to base the revision upon", ), ): home = MigrationHome(alembic_home_dir) home.rebase(revision, *new_bases)
def test_rebase__fails_if_new_ancestry_is_incoherent(self, scripts_dir): home = MigrationHome(scripts_dir) with pytest.raises(AmbixError, match="Cannot rebase"): home.rebase("dddddd", "gggggg")