heroku如何运行python manage.py迁移?

khu*_*bui 4 python django heroku

我在Heroku中部署了一个简单的Django应用

脚步:

- git push heroku master

- heroku run python manage.py makemigrations ( or + app_name)
Run Code Online (Sandbox Code Playgroud)

它似乎影响:

  0002_main.py:
- Create model Comment
- Remove field status from match
- Remove field quantity from slot
- Add field avatar to account
- Add field slots to match
- Alter field verification_code on account
- Alter field verification_code on slot
- Add field match_object to comment
- Add field user to comment
- Alter index_together for comment (1 constraint(s))
Run Code Online (Sandbox Code Playgroud)

然后我跑

- heroku run python manage.py migrate
Run Code Online (Sandbox Code Playgroud)

但我收到了:

  Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Run Code Online (Sandbox Code Playgroud)

Zam*_*zal 6

确保已提交迁移文件。然后跑

heroku run python manage.py migrate
Run Code Online (Sandbox Code Playgroud)

请参阅此文档。


Say*_*yse 5

您的迁移文件应提交给源代码管理,并且切勿makemigrations在heroku上运行。

对于已提交的迁移文件,此问题不再存在。