Skip to content

downgrade with depedencies leaves revision table in broken state #789

Description

@hcpatel

Describe your question
My use case is 2 branches with their own base to start with, where subsequent revisions from BranchB will depend on BranchA. Each new revision on BranchB I always specify a 'depends on' BranchA (usually --depend_on=branchA@head). But I an finding an issue upgrading to the head of BranchB after I run a downgrade of the latest revision on BranchB (using alembic upgrade heads).
Initially I thought it could be an issue with downgrade, but after some testing realised perhaps it the 'mis-use' of 'depends-on' on BranchB.
Hence, looking for advice here, in that should 'depends-on' only be used in certain circumstances? ie. when there is a need to run revision from BranchA before BranchB?

Example (if applicable)
The state of my alembic history:

BranchA: (base) revA1 ---> revA2 ---> revA3 ---> revA4 ---> revA5 ---> revA6
                                        \                                \
                                         \ (revB2 depends_on revA3)       \ (revB3 depends_on revA6)
                                          \                                \
BranchB: (base) revB1 -------------------------> revB2 --------------------------> revB3 ---> revB4 (with depends_on=revA6)

When I run 'alembic upgrade heads', I find 'alembic_version' table has only 'revB4'.
Then I add a new revision 'revB5' on top of 'revB4' with SAME depends on BranchA (ie. revA6) :

BranchA: (base) revA1 ---> revA2 ---> revA3 ---> revA4 ---> revA5 ---> revA6
                                        \                                \
                                         \ (revB2 depends_on revA3)       \ (revB3 depends_on revA6)
                                          \                                \
BranchB: (base) revB1 -------------------------> revB2 --------------------------> revB3 ---> revB4 --> revB5 (with depends_on=revA6)

On running 'alembic upgrade heads', the 'alembic_version' table has 'revB5' only.

Now when I run 'alembic downgrade BranchB@revB4 , the alembic_version table has 'revB4' AND 'revA6'. But this is not same as 'before', as it only had 'revB4'.

Now any attempt to upgade (alembic upgrade heads) fails with:

ERROR [alembic.util.messaging] Requested revision revA6 overlaps with other requested revisions revB5
FAILED: Requested revision revA6 overlaps with other requested revisions revB5

The only way I can make this work is manually delete 'revA6', then the upgrade works as per before.

Hence, is this a bug/issue for 'downgrade', as it should not have inserted 'revA6' into the alembic_version table.
OR should revB5 and revB4 be created with no '--depends-on=revA6', as the previous revision already has this dependency.

So next I tested this (alembic 1.5.2), by modifying the revB5 (depends-on to blank). Then I found I can downgrade to revB4 and upgrade to revB5 successfully.

Hence, looking for clarification on when 'depends-on' should be used, when using multiple branches (with separate base)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions