Git Product home page Git Product logo

flask-alembic's People

Contributors

davidism avatar dependabot[bot] avatar kumy avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flask-alembic's Issues

BitBucket or GitHub?

The docs say:

The latest code is hosted on BitBucket.

But the docs also include "Edit on GitHub" and the code is here. Maybe they are mirrored? Just thought I'd mention the possible confusion.

CLI downgrade command raises exception

When calling db downgrade without any arguments from my Flask app, I get following:

  File "my_project/.venv/lib/python3.11/site-packages/flask_alembic/cli.py", line 118, in downgrade
    alembic.downgrade(target)
  File "my_project/.venv/lib/python3.11/site-packages/flask_alembic/extension.py", line 408, in downgrade
    self.run_migrations(do_downgrade)
  File "my_project/.venv/lib/python3.11/site-packages/flask_alembic/extension.py", line 272, in run_migrations
    env.run_migrations(**kwargs)
  File "my_project/.venv/lib/python3.11/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
    self.get_context().run_migrations(**kw)
  File "my_project/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 615, in run_migrations
    for step in self._migrations_fn(heads, self):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "my_project/.venv/lib/python3.11/site-packages/flask_alembic/extension.py", line 403, in do_downgrade
    return self.script_directory._downgrade_revs(  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "my_project/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 473, in _downgrade_revs
    return [
           ^
  File "my_project/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 473, in <listcomp>
    return [
           ^
  File "my_project/.venv/lib/python3.11/site-packages/alembic/script/revision.py", line 813, in iterate_revisions
    revisions, heads = fn(
                       ^^^
  File "my_project/.venv/lib/python3.11/site-packages/alembic/script/revision.py", line 1330, in _collect_downgrade_revisions
    branch_label, target_revision = self._parse_downgrade_target(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "my_project/.venv/lib/python3.11/site-packages/alembic/script/revision.py", line 1112, in _parse_downgrade_target
    assert isinstance(
AssertionError: Expected downgrade target in string form

I did some debugging to ensure that alembic.downgrade(target) is called with default argument and it looks like this:

alembic.downgrade("-1")

problem happens here:

# flask-alembic/extension.py
def downgrade(self, target: int | str | Script = -1) -> None:
    """Run migrations to downgrade database.

    :param target: Revision to go down to.
    """
    target_arg = self._simplify_rev(target, handle_int=True)

    def do_downgrade(
        revision: str | list[str] | tuple[str, ...], context: MigrationContext
    ) -> list[MigrationStep]:
        return self.script_directory._downgrade_revs(  # type: ignore[return-value]
            target_arg,  # type: ignore[arg-type]
            revision,  # type: ignore[arg-type]
        )

self._simplify_rev() always returns list of strings, but notice that method _downgrade_revs in alembic is declared as following:

# alembic/script/base.py
def _downgrade_revs(
    self, destination: str, current_rev: Optional[str]
) -> List[RevisionStep]:
    ...

No time to dig deeper, hope that above helps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.