pythonflasksqlalchemyflask-sqlalchemyalembic

How do I delete a similar alembic version?


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!


Solution

  • 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.