Skip to content

MacOS 15 下 alembic upgrade head 报错 #2

Description

@HolmesZhao

环境 MacOS 15, mysql 9.2.0-arm64

执行 alembic revision --autogenerate -m "initial migration" 是成功的, 但是执行 alembic upgrade head 报错如下:

$ alembic upgrade head

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> e8aec29bebdc, initial migration
Traceback (most recent call last):
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/bin/alembic", line 8, in <module>
    sys.exit(main())
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/config.py", line 636, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/config.py", line 626, in main
    self.run_cmd(cfg, options)
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/config.py", line 603, in run_cmd
    fn(
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/command.py", line 406, in upgrade
    script.run_env()
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/script/base.py", line 586, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/zhaowuyi/Downloads/fu-fastapi-vue-master/backend/alembic/env.py", line 92, in <module>
    run_migrations_online()
  File "/Users/zhaowuyi/Downloads/fu-fastapi-vue-master/backend/alembic/env.py", line 86, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/Users/zhaowuyi/.pyenv/versions/3.10.6/lib/python3.10/site-packages/alembic/runtime/migration.py", line 628, in run_migrations
    step.migration_fn(**kw)
  File "/Users/zhaowuyi/Downloads/fu-fastapi-vue-master/backend/alembic/versions/e8aec29bebdc_initial_migration.py", line 32, in upgrade
    sa.Column('dept_id', common.fu_model.UUIDStr(length=36), nullable=True, comment='User Department'),
NameError: name 'common' is not defined

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

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions