0

I have updated my model, but I couldn't do the migrations, the problem is:

I am getting an error like: column "blah blah" of relation "blah blah blah" already exists

The mentioned column should exist in DB, but it shouldn't exist on migration file because I did not do any addition or modification about that model field and it was already successfully created in one of the previous migrations, even used frequently without any error.

When I do the migration with --fake, this time it doesn't create the really unexisting field of migration file which is defined with that model update.

Deployed on Heroku, it may be caused by rollbacks of code layer, since after rollbacks code gets to older versions but DB stays same.

What is the best way without losing any data from production DB?

Following is a screenshot of the bash; timezone, endtime and start time fields already exist on model and DB before this migration, created on one of the previous successful migrations

Click here to screenshot of Heroku Bash when I try to run migrations

Thanks

Sinan Sari
  • 51
  • 1
  • 8

1 Answers1

0

You should not be running makemigrations on Heroku. Do it locally, then commit the result, deploy, and then run migrate only.

As it is, you've got completely out of sync; if you don't have any data you need to keep, the easiest thing to do is to delete your db and start again.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895