如何heroku运行python manage.py迁移? [英] How heroku run python manage.py migrate?

查看:176
本文介绍了如何heroku运行python manage.py迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

步骤:

   -  git push heroku master 

- heroku run python manage.py makemigrations(或+ app_name)

它似乎会影响:

  0002_main.py:
- 创建模型Comment
- 从匹配
中删除字段状态 - 从插槽中删除字段数量
- 将字段头像添加到帐户
- 添加字段插槽以匹配
- 更改帐户$ b上的字段验证码$ b - 更改插槽
上的field verification_code - 将字段match_object添加到注释
- 将字段用户添加到注释
- 更改index_together用于注释(1个约束)

然后我运行

  -  heroku run python manage.py migrate 

但我收到:

 运行迁移:
不适用迁移。
您的模型所做的更改尚未反映在迁移中,因此不会应用。
运行'manage.py makemigrations'进行新的迁移,然后重新运行'manage.py migrate'以应用它们。


解决方案

您的迁移文件应该提交给您的源代码管理,并且永远不会在heroku上运行 makemigrations



使用提交的迁移文件,这个问题变得不存在。


I deployed a simple Django app in Heroku

Steps:

- git push heroku master

- heroku run python manage.py makemigrations ( or + app_name)

it seem to affect:

  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))

then I run

- heroku run python manage.py migrate

but i received:

  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.

解决方案

Your migration files should be committed to your source control, and never run makemigrations on heroku.

With committed migration files, this problem becomes non existant.

这篇关于如何heroku运行python manage.py迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆