Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask-Migrate fails with flask version 2.1.3 #475

Closed
ghost opened this issue Jul 27, 2022 · 5 comments
Closed

Flask-Migrate fails with flask version 2.1.3 #475

ghost opened this issue Jul 27, 2022 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 27, 2022

We are using Flask-Migrate(version 3.1.0) from a long time and it used to work fine with our previous flask version BUT after upgrading our Flask version to 2.1.3 it's producing the below error on any flask db command

Traceback (most recent call last):
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask/cli.py", line 986, in main
    cli.main()
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask/cli.py", line 567, in main
    return super().main(*args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask/cli.py", line 407, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask_migrate/cli.py", line 104, in migrate
    _migrate(directory, message, sql, head, splice, branch_label, version_path,
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask_migrate/__init__.py", line 98, in wrapped
    f(*args, **kwargs)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/flask_migrate/__init__.py", line 155, in migrate
    command.revision(config, message, autogenerate=True, sql=sql,
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/command.py", line 229, in revision
    script_directory.run_env()
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/base.py", line 569, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "migrations/env.py", line 98, in <module>
    run_migrations_online()
  File "migrations/env.py", line 92, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/runtime/environment.py", line 853, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/runtime/migration.py", line 611, in run_migrations
    for step in self._migrations_fn(heads, self):
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/command.py", line 205, in retrieve_migrations
    revision_context.run_autogenerate(rev, context)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/autogenerate/api.py", line 526, in run_autogenerate
    self._run_environment(rev, migration_context, True)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/autogenerate/api.py", line 544, in _run_environment
    if set(self.script_directory.get_revisions(rev)) != set(
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/base.py", line 296, in get_revisions
    self.revision_map.get_revisions(id_),
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/revision.py", line 527, in get_revisions
    return sum([self.get_revisions(id_elem) for id_elem in id_], ())
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/revision.py", line 527, in <listcomp>
    return sum([self.get_revisions(id_elem) for id_elem in id_], ())
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/revision.py", line 552, in get_revisions
    return tuple(
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/revision.py", line 553, in <genexpr>
    self._revision_for_ident(rev_id, branch_label)
  File "/Users/vinitpayal/engineering/tribes/codes/backend-api-python-3/venv/lib/python3.9/site-packages/alembic/script/revision.py", line 613, in _revision_for_ident
    assert resolved_id
AssertionError

The error appears on all

flask db migrate -m
flask db upgrade

The error is being raised from a function named _revision_for_ident in dependency alembic BUT not sure what can be the cause of it and have no idea about how we can get it fixed.

@miguelgrinberg
Copy link
Owner

I'm not aware of any incompatibilities, and I don't see this error here. Can you share the output of pip freeze? I wonder if you are using a very old version of Alembic, maybe.

@ghost
Copy link
Author

ghost commented Jul 27, 2022

Thanks @miguelgrinberg for responding, Attaching output of pip freeze

aiohttp==3.8.1
aiosignal==1.2.0
alembic==1.8.1
aniso8601==7.0.0
async-timeout==4.0.2
attrs==21.4.0
CacheControl==0.12.11
cachetools==4.2.4
certifi==2022.6.15
cffi==1.15.1
chargebee==2.17.0
charset-normalizer==2.1.0
click==8.1.3
cryptography==3.4.5
firebase-admin==4.5.1
Flask==2.1.3
Flask-GraphQL==2.0.1
Flask-Migrate==3.1.0
Flask-SQLAlchemy==2.4.4
frozenlist==1.3.0
google-api-core==1.32.0
google-api-python-client==1.12.8
google-auth==1.35.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.5.2
google-cloud-bigquery==2.8.0
google-cloud-core==1.7.3
google-cloud-firestore==2.6.0
google-cloud-kms==2.2.0
google-cloud-profiler==4.0.0
google-cloud-storage==1.32.0
google-cloud-tasks==1.5.0
google-crc32c==1.3.0
google-resumable-media==1.3.3
googleapis-common-protos==1.56.4
graphene==2.1.8
graphql-core==2.3.2
graphql-relay==2.0.1
graphql-server==3.0.0b4
graphql-server-core==1.2.0
grpc-google-iam-v1==0.12.4
grpcio==1.47.0
gspread==4.0.1
httplib2==0.20.4
idna==3.3
importlib-metadata==4.12.0
itsdangerous==2.0.1
Jinja2==3.0.3
joblib==1.1.0
libcst==0.4.7
Mako==1.2.1
MarkupSafe==2.1.1
marshmallow==3.17.0
msgpack==1.0.4
multidict==6.0.2
mypy-extensions==0.4.3
mysqlclient==2.0.3
numpy==1.20.2
oauthlib==3.2.0
packaging==21.3
pandas==1.1.5
promise==2.3
proto-plus==1.20.6
protobuf==3.20.0
publicsuffixlist==0.7.12
pyarrow==3.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
PyJWT==1.7.1
PyMySQL==1.0.2
pyparsing==2.4.7
python-dateutil==2.8.2
pytz==2022.1
PyYAML==6.0
redis==3.5.3
requests==2.28.1
requests-oauthlib==1.3.1
rsa==4.9
Rx==1.6.1
scikit-learn==0.24.2
scipy==1.8.1
six==1.16.0
slackclient==2.9.3
SQLAlchemy==1.3.23
sqlalchemy-filters==0.12.0
SQLAlchemy-serializer==1.3.4.4
threadpoolctl==3.1.0
typing-extensions==3.10.0.2
typing-inspect==0.7.1
uritemplate==3.0.1
urllib3==1.26.11
webargs==6.1.1
Werkzeug==2.0.3
yarl==1.7.2
zipp==3.8.1

@ghost
Copy link
Author

ghost commented Jul 27, 2022

Regarding not seeing error, the above attached is actually the entire stack trace. Please let me know if can provide any other details.

@miguelgrinberg
Copy link
Owner

Are you sure you don't have an invalid or outdated alembic_versions table in your database? I just don't see this error here, not sure what it might be, but there is some sort if issue between alembic and your database.

@ghost
Copy link
Author

ghost commented Aug 5, 2022

Thanks @miguelgrinberg, will have a look but don't think there's anything wrong with it as we never update the values manually in alembic_versions table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant