Django在Heroku上-向PostgreSQL数据库添加新模型

时间:2019-04-25 15:58:59

标签: django heroku migrate

我有一个在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.

我试图逐步进行,这意味着我一个接一个地添加每个丢失的字段,但这也导致了本质上相同的问题。

1 个答案:

答案 0 :(得分:2)

请勿使用assert @event.seats == 0创建迁移文件。

  1. 在本地运行heroku run
  2. 签入新的迁移文件
  3. 将更改推送到git
  4. 现在,您可以使用python manage.py makemigrations
  5. 迁移数据库