我正在尝试使用 flask-migrate 在本地对我的数据库进行版本控制,然后反映生产中的更改(Heroku)。到目前为止,我成功地对本地数据库进行了版本控制并对其进行了升级,所以现在我想在 Heroku 上反映这一点。为此,我将最新的代码状态连同新创建的迁移文件夹和更新的 requirements.txt 一起推送到 Heroku。我看到依赖项已成功安装:
Successfully installed Flask-Migrate alembic Flask-Script Mako
然后,我尝试了:
$ heroku run python app/hello.py db upgrade
不幸的是,我得到了这个回应:
Running `python app/hello.py db upgrade` attached to terminal... up, run.4322
Traceback (most recent call last):
File "app/hello.py", line 37, in <module>
manager.run()
File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 405, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 384, in handle
return handle(app, *positional_args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/commands.py", line 145, in handle
return self.run(*args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/flask_migrate/__init__.py", line 97, in upgrade
config = _get_config(directory)
File "/app/.heroku/python/lib/python2.7/site-packages/flask_migrate/__init__.py", line 37, in _get_config
config.set_main_option('script_location', directory)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/config.py", line 142, in set_main_option
self.file_config.set(self.config_ini_section, name, value)
File "/app/.heroku/python/lib/python2.7/ConfigParser.py", line 753, in set
ConfigParser.set(self, section, option, value)
File "/app/.heroku/python/lib/python2.7/ConfigParser.py", line 396, in set
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'alembic'
我用谷歌搜索这可能是什么,看起来配置文件无法打开,但是我不知道可以做些什么来解决这个问题。为什么这在本地有效,但在 Heroku 上无效?