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()