[英]Django on Heroku - add new models to postgreSQL database
I have an Django 2.1 / Python 3.6 application running on Heroku's hobby account.我有一个在 Heroku 的爱好帐户上运行的 Django 2.1 / Python 3.6 应用程序。 The first version of this deployment went smoothly.
此部署的第一个版本进行得很顺利。 Now I needed to add more fields to existing models and also add additional models from my local setup (which is running very smoothly with the changes) to Heroku.
现在我需要向现有模型添加更多字段,还需要从我的本地设置(随着更改运行得非常顺利)向 Heroku 添加其他模型。 I do the usual
我照常做
git push heroku master
to get the new code over to Heroku.将新代码移交给 Heroku。 Then I do both
然后我都做
heroku run python manage.py makemigrations
heroku run python manage.py migrate
The first step gives me第一步给了我
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
which is fine, but the migrate is also coming back with the message很好,但是迁移也会返回消息
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.
I tried to go step by step, meaning I add each missing field one after the other, but this also leads to the essentially same problem.我试着一步一步来,这意味着我一个接一个地添加每个缺失的字段,但这也会导致本质上相同的问题。
Don't use heroku run
to create the migration files.不要使用
heroku run
创建迁移文件。
python manage.py makemigrations
locallypython manage.py makemigrations
heroku run python manage.py migrate
heroku run python manage.py migrate
迁移您的数据库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.