From af67bb093df5652c867b88880c5934bfc68313cc Mon Sep 17 00:00:00 2001 From: Jono N <54155138+hurtleturtle@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:56:30 +0000 Subject: [PATCH] Add --purge flag to the stamp command (#540) --- src/flask_migrate/__init__.py | 4 ++-- src/flask_migrate/cli.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 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 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()