From 4011691443dae00a42fd13bffe7e816aaacb643b Mon Sep 17 00:00:00 2001 From: Jono Date: Thu, 7 Mar 2024 12:00:01 +0000 Subject: [PATCH 1/2] Update stamp function to pass purge to alembic command --- src/flask_migrate/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flask_migrate/__init__.py b/src/flask_migrate/__init__.py index f0f9301..d12a097 100644 --- a/src/flask_migrate/__init__.py +++ b/src/flask_migrate/__init__.py @@ -252,11 +252,11 @@ def current(directory=None, verbose=False): @catch_errors -def stamp(directory=None, revision='head', sql=False, tag=None): +def stamp(directory=None, revision='head', sql=False, tag=None, purge=False): """'stamp' the revision table with the given revision; don't run any migrations""" config = current_app.extensions['migrate'].migrate.get_config(directory) - command.stamp(config, revision, sql=sql, tag=tag) + command.stamp(config, revision, sql=sql, tag=tag, purge=purge) @catch_errors From b5967d37c6a59c1838b3d6233f48563837b507cf Mon Sep 17 00:00:00 2001 From: Jono Date: Thu, 7 Mar 2024 12:06:10 +0000 Subject: [PATCH 2/2] Add --purge flag to stamp command --- src/flask_migrate/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/flask_migrate/cli.py b/src/flask_migrate/cli.py index 5bfd4b5..73a31ba 100644 --- a/src/flask_migrate/cli.py +++ b/src/flask_migrate/cli.py @@ -238,12 +238,15 @@ def current(directory, verbose): @click.option('--tag', default=None, help=('Arbitrary "tag" name - can be used by custom env.py ' 'scripts')) +@click.option('--purge', is_flag=True, + help=('Delete the version in the alembic_version table before ' + 'stamping')) @click.argument('revision', default='head') @with_appcontext -def stamp(directory, sql, tag, revision): +def stamp(directory, sql, tag, revision, purge): """'stamp' the revision table with the given revision; don't run any migrations""" - _stamp(directory, revision, sql, tag) + _stamp(directory, revision, sql, tag, purge) @db.command()