shuboy2014 shuboy2014 - 2 years ago 317
Python Question

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 .

H:\shuboy2014>heroku run python makemigrations posts
Running python makemigrations posts on shuboy2014... up, run.9067
Migrations for 'posts':
- Alter field slug on post

H:\shuboy2014>heroku run python migrate
Running python 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 ' makemigrations' to make new migrations, and then re-run ' migrate' to apply them.

Any helpful suggestions will be appreciable .

Answer Source

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.

You should generate migrations locally, committing and pushing them, and then executing the heroku run python migrate command.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download