When I am trying to do
alembic upgrade head
I am getting this error:
ERROR [alembic.util.messaging] Online migration expected to match one row when updating '3aae6532b560' to 'a1d8dae7cc' in 'alembic_version'; 2 found
FAILED: Online migration expected to match one row when updating '3aae6532b560'
to 'a1d8dae7cc' in 'alembic_version'; 2 found
alembic current
gives two similar versions of alembic like:
3aae6532b560
3aae6532b560
How do I delete one of the similar versions of alembic, i.e a copied version?
alembic history doesn't show any messed up output.
Thanks!
If you want to run to downgrade() of a version, you will need to run alembic downgrade the-version-before-it , which mean it will revert to the version after the version that you want to downgrade. Which is the version before the version that we want to revert.
run pip freeze | grep "alembic" .
Alembic is the migration tool we use with SQLAlchemy. Alembic provides us with a simple way to create and drop tables, and add, remove, and alter columns. Fork and clone this repository and we'll walk through writing Alembic migrations together. To install Alembic, run pip install alembic in your terminal.
Show activity on this post. Delete (or move to another folder) the specific migration file (in migrations/versions folder). The head will automatically revert to the most recent remaining migration. Using stamp will set the db version value to the specified revision; not alter the head revision number.
Alembic version is stored within your database in alembic_version table. I see that you have two self same rows inside the table.
You can do something like this:
DELETE FROM alembic_version WHERE version_num='3aae6532b560';
INSERT INTO alembic_version VALUES ('3aae6532b560');
Above query could be done in one query by limiting number of deleted rows, but limiting within DELETE query is different between different databases engines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With