Heroku上的Django - 为postgreSQL数据库添加新模型

问题描述 投票:1回答:1

我有一个在Heroku的爱好帐户上运行的Django 2.1 / Python 3.6应用程序。这个部署的第一个版本进展顺利。现在我需要向现有模型添加更多字段,并且还需要从我的本地设置(运行非常顺利)中添加其他模型到Heroku。我照常做的

git push heroku master

将新代码传递给Heroku。然后我两个都做

heroku run python manage.py makemigrations
heroku run python manage.py migrate

第一步给了我

Running python manage.py makemigrations on ⬢ hirt-family-v4... up, run.3753 (Free)
Migrations for 'users':
users/migrations/0005_auto_20190425_1452.py
- Create model XtraPhotos
- Add field phone_number to person
- Add field parent to xtraphotos

这很好,但迁移也随着消息回来

Running python manage.py migrate on ⬢ hirt-family-v4... up, run.5929 (Free)


Operations to perform:


Apply all migrations: account, admin, auth, contenttypes, sessions, sites, users


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.

我试图一步一步地走,这意味着我一个接一个地添加每个缺失的字段,但这也导致了基本相同的问题。

django heroku migrate
1个回答
2
投票

不要使用heroku run来创建迁移文件。

  1. 在本地运行python manage.py makemigrations
  2. 签入新的迁移文件
  3. 将更改推送到git
  4. 现在,您可以使用heroku run python manage.py migrate迁移数据库
© www.soinside.com 2019 - 2024. All rights reserved.