Describe the bug
I tried executing the stamp command by passing "base" as the target revision. Instead of deleting the table Alembic confirms the existence of the alembic_version table and then returns.
What is even more strange is that when calling the command using the --sql function you get the expected behavior:
$ alembic stamp --sql base
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Generating static SQL
INFO [alembic.runtime.migration] Will assume transactional DDL.
BEGIN;
DROP TABLE alembic_version;
COMMIT;
Expected behavior
Alembic should delete the alembic_version even if there are no migrations, as it creates the table if there are no migrations.
To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
- Start a Postgresql server:
docker run --name some-postgres -p 54321:5432 -e POSTGRES_PASSWORD=letmein postgres:18
- Initialize Alembic in a folder:
alembic init
- Edit the configuration to point at the database:
sqlalchemy.url = postgresql://postgres:letmein@localhost:54321/postgres
- Stamp the database:
alembic stamp head
- Check the status of the table in the database:
select * from alembic_version;. This should return an empty table
- Clear the database:
alembic stamp base
- The command from step
6 will still return an empty table instead of erroring out because the table doesn't exist anymore.
Versions.
- OS:
Linux 7.0.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 10 Jun 2026 08:58:02 +0000 x86_64 GNU/Linux
- Python:
3.14.5
- Alembic:
1.18.4
- SQLAlchemy:
2.0.51
- Database: Postgresql
18.4
- DBAPI: Psycopg
3.3.4
Describe the bug
I tried executing the
stampcommand by passing"base"as the target revision. Instead of deleting the table Alembic confirms the existence of thealembic_versiontable and then returns.What is even more strange is that when calling the command using the
--sqlfunction you get the expected behavior:Expected behavior
Alembic should delete the
alembic_versioneven if there are no migrations, as it creates the table if there are no migrations.To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
docker run --name some-postgres -p 54321:5432 -e POSTGRES_PASSWORD=letmein postgres:18alembic initsqlalchemy.url = postgresql://postgres:letmein@localhost:54321/postgresalembic stamp headselect * from alembic_version;. This should return an empty tablealembic stamp base6will still return an empty table instead of erroring out because the table doesn't exist anymore.Versions.
Linux 7.0.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 10 Jun 2026 08:58:02 +0000 x86_64 GNU/Linux3.14.51.18.42.0.5118.43.3.4