Skip to content

upgrading to implicit head that's already applied emits error message when it should likely pass silently, as is the case for normal heads already applied #336

@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by Cedric Shock

alembic 0.8.0 fails upgrades to a head that another branch depends_on.

We are going to create the following revision graph.

base --- core 1 (core@head)
               \_____
                     \
base --- branch 1 --- branch 2 (branch@head)

Upgrading to core@head is successful until we upgrade to branch@head. After upgrading to branch@head, subsequent upgrades to core@head fail with the message Destination core@head is not a valid upgrade target from current head(s).

The following commands set up the desired revision graph.

alembic init alembic
alembic revision -m "core 1" --head=base --branch-label=core
alembic revision -m "branch 1" --head=base --branch-label=branch
alembic revision -m "branch 2" --head=branch@head --depends-on=core@head

Upgrading to core@head is successful multiple times in a row.

$ alembic upgrade core@head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 50e7acdb8305, core 1
$ alembic upgrade core@head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

We can upgrade to branch@head.

$ alembic upgrade branch@head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> f65508c78e3, branch 1
INFO  [alembic.runtime.migration] Running upgrade f65508c78e3, 50e7acdb8305 -> 1f50b22f2131, branch 2

But if we now try to upgrade to core@head again we get an error.

$ alembic upgrade core@head
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [alembic.util.messaging] Destination core@head is not a valid upgrade target from current head(s)
  FAILED: Destination core@head is not a valid upgrade target from current head(s)

The error is a result of alembic.script.revision.RevisionMap.iterate_revisions raising RangeNotAncestorError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions