Flask database migrations on heroku

二次信任 提交于 2020-05-10 06:24:07

问题


With my app I am using flask-script and flask-migrate for database migrations, everything works locally. When, I run

heroku run python manage.py db init

It creates this output:

Running python manage.py db init on ⬢ fpds-scheduler... up, run.1290 (Free)
  Creating directory /app/migrations ... done
  Creating directory /app/migrations/versions ... done
  Generating /app/migrations/README ... done
  Generating /app/migrations/script.py.mako ... done
  Generating /app/migrations/alembic.ini ... done
  Generating /app/migrations/env.py ... done
  Please edit configuration/connection/logging settings in '/app/migrations/alembic.ini' before
  proceeding.

But when I run heroku run python manage.py db migrate I get an error

alembic.util.exc.CommandError: Path doesn't exist: 'migrations'.  Please use the 'init' command to create a new scripts folder.

When I run heroku run bash and look at my directory I can see that there is no migrations folder...

I have tried running giving the command --app fpds-scheduler but that doesn't seem to be working either.

I am not sure what is going wrong?


回答1:


You must not create the migrations on Heroku itself. The filesystem is ephemeral and anything written programatically will be lost between invocations.

You need to create the migrations locally, commit them to version control, deploy, and only then run them on Heroku.



来源:https://stackoverflow.com/questions/46430061/flask-database-migrations-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!