【发布时间】:2016-10-08 20:46:32
【问题描述】:
我的项目托管在 heroku 上,最近我想更改一列的大小 在数据库中 但是在运行 makemigrations 命令和 migrate 命令后,它给出了一个错误,我不想丢失我的数据。
H:\shuboy2014>heroku run python manage.py makemigrations posts
Running python manage.py makemigrations posts on shuboy2014... up, run.9067
Migrations for 'posts':
0003_auto_20160608_1404.py:
- Alter field slug on post
H:\shuboy2014>heroku run python manage.py migrate
Running python manage.py migrate on shuboy2014... up, run.3731
Operations to perform:
Apply all migrations: admin, contenttypes, posts, sessions, auth
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.
任何有用的建议都将不胜感激。
【问题讨论】:
-
您确定您的更改已反映在迁移文件中吗?
-
但是我如何在 heroku 上查看它?
-
无论如何,您都应该将迁移文件提交到源代码管理,我不确定您在这里问什么
-
@Sayse 我直接在服务器上运行迁移命令,这就是为什么我的迁移没有反映在数据库上。
-
但是你永远不需要在服务器上运行
makemigrations。
标签: python django heroku django-models