Skip to content

Unexpected downgrade behaviour in branch cases #765

Description

@simonbowly

A few cases of unexpected behaviour of downgrade when there are multiple current/head revisions. See #766 for tests that reproduce these issues.

Versions.

  • OS: Ubuntu 20.04 LTS
  • Python: 3.8.6
  • Alembic: 1.4.3 (and current master branch)
  • SQLAlchemy: 1.3.20
  • Database: any
  • DBAPI: any

1. Unexpected test case behaviour:

Expected base+2 to downgrade to revision b regardless of the branch label.

self._assert_downgrade(
"c2branch@base+2",
[self.d2.revision, self.d1.revision],
[self.down_(self.d2), self.down_(self.c2), self.down_(self.d1)],
set([self.c1.revision]),
)

2. downgrade -1 behaviour depends on branch order:

This behaves as documented but it's difficult to determine the order in advance from the user's perspective.

Tree structure:

base -> rev1 --> rev2 (brancha)
             +-> rev2a (branchb) -> rev3a

Perhaps this should fail since the meaning of the relative revision is ambiguous?

alembic downgrade base
alembic upgrade rev3a
alembic upgrade rev2
alembic downgrade -1
=> INFO  [alembic.runtime.migration] Running downgrade rev3a -> rev2a, rev3a
alembic downgrade base
alembic upgrade rev2
alembic upgrade rev3a
alembic downgrade -1
=> INFO  [alembic.runtime.migration] Running downgrade rev2 -> rev1, rev2

3. downgrade revision-1 behaviour breaks with certain branch orders:

Runs too many revisions (one on the wrong branch) in some cases. This behaviour is dependent on upgrade order.

Tree structure:

base -> rev1 --> rev2 (brancha)
             +-> rev2a (branchb) -> rev3a

Works as expected:

alembic downgrade base
alembic upgrade rev3a
alembic upgrade rev2
alembic downgrade rev3a-1
=> INFO  [alembic.runtime.migration] Running downgrade rev3a -> rev2a, rev3a

Downgrades both branches once for same revision if upgrade are carried out in the opposite order:

alembic downgrade base
alembic upgrade rev2
alembic upgrade rev3a
alembic downgrade rev3a-1
=> INFO  [alembic.runtime.migration] Running downgrade rev2 -> rev1, rev2
=> INFO  [alembic.runtime.migration] Running downgrade rev3a -> rev2a, rev3a

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions