错误日志如下,代码是copy《flask web 开发》
lanxiang@machine:~/bushu2$ heroku run python manage.py deploy
Running python manage.py deploy on ⬢ x1996... up, run.8593
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running upgrade None -> f3893df0869f, init migrations
Traceback (most recent call last):
File "manage.py", line 81, 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 "manage.py", line 71, in deploy
upgrade()
File "/app/.heroku/python/lib/python2.7/site-packages/flask_migrate/__init__.py", line 98, in upgrade
command.upgrade(config, revision, sql = sql, tag = tag)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/command.py", line 124, in upgrade
script.run_env()
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/script.py", line 199, in run_env
util.load_python_file(self.dir, 'env.py')
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util.py", line 199, in load_python_file
module = load_module(module_id, path)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/compat.py", line 55, in load_module
mod = imp.load_source(module_id, path, fp)
File "migrations/env.py", line 72, in <module>
run_migrations_online()
File "migrations/env.py", line 65, in run_migrations_online
context.run_migrations()
File "<string>", line 7, in run_migrations
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/environment.py", line 652, in run_migrations
self.get_context().run_migrations(**kw)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/migration.py", line 225, in run_migrations
change(**kw)
File "migrations/versions/f3893df0869f_init_migrations.py", line 27, in upgrade
op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
AttributeError: 'module' object has no attribute 'f'
應該是資料庫遷移問題,如果修改遷移檔案可能對你現階段來說有點困難。
既然是學習階段,我暫時認為你的資料庫沒有重要資料,那建議你這樣操作:
刪除本地資料庫
刪除遷移資料夾
再試一次
給你一篇我的部落格參考一下,可能有不全面的地方,但是應該能幫助你理解的。
我在文中提出的幾點建議個人認為真的很重要,建議讀完後再刪除和重新部署。
Flask 資料庫遷移與部署的一些經驗
如果你有興趣,可以順藤摸瓜看看我當時在那個論壇的回答,有上下文可以理解。
再給你一些小建議:
要學會看報錯提示
是要理解遷移功能