简体   繁体   English

我如何解决在heroku上托管的Django项目中的迁移问题?

[英]How can i solve a migration issue in django project hosted on heroku?

My project hosted on heroku and recently i want to change the size of one column in db but after running makemigrations command and then migrate command it gives an error and i don't want to lose my data . 我的项目托管在Heroku最近我想换一列的大小以dB为单位,但运行makemigrations命令后,然后再迁移命令时,它给出了一个错误,我不想失去我的数据。

   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.

Any helpful suggestions will be appreciable . 任何有用的建议将是可理解的。

heroku run commands run on One-Off Dynos with an ephemeral file system, so you are generating the migrations files on a file system that is immediately destroyed. heroku run命令在具有短暂文件系统的一次性Dynos上运行,因此您正在立即销毁的文件系统上生成迁移文件。

You should generate migrations locally, committing and pushing them, and then executing the heroku run python manage.py migrate command. 您应该在本地生成迁移,提交并推送它们,然后执行heroku run python manage.py migrate命令。

I just run makemigrations and migrate command on my local computer and then push it on heroku and run both commands again and its done . 我只是再次运行makemigrations和我的本地计算机上的迁移命令,然后将其推在Heroku和运行命令和它的完成。

 H:\shuboy2014>heroku run python manage.py migrate
 Running python manage.py migrate on shuboy2014... up, run.6192
 Operations to perform:
   Apply all migrations: contenttypes, auth, posts, sessions, admin
 Running migrations:
   Rendering model states... DONE
   Applying posts.0003_auto_20160608_2001... OK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何正确地将Python库导入Django项目(托管在Heroku中)? - How to correctly import a Python library into a Django project (hosted on Heroku)? 我该如何解决这个 pipenv 安装错误 - vscode 上的 django 项目 - how can i solve this pipenv install error - django project on vscode 如何在不更改模型的情况下解决 django 中的这个问题? - How can I solve this issue in django without changing the models? 将 Django 项目部署到 Heroku 时如何解决服务器错误 (500)? - How to solve server error (500) while deploying Django project to Heroku? 我无法在Heroku上注册我的Django项目 - I can not register my Django project on Heroku 如何解决 heroku 上的应用程序错误? - How can I solve application error on heroku? 我在 Django Heroku 中收到此错误 Application Error 如何解决? - I get this error Application Error in Django Heroku HOW to solve it? 我该如何解决这个错误? 我正在和 django 一起做一个学校项目,但我被困住了 - How can i solve this error? I'm working with django on a school project and i'm stuck 如何解决应用程序的 29 个未应用的迁移:admin、api、auth、authtoken、contenttypes、sessions、social_django - How can I solve the 29 unapplied migration(s) for app(s): admin, api, auth, authtoken, contenttypes, sessions, social_django 如何解决这个 Flask 数据库迁移错误? - How can I solve this Flask database migration error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM