0

I have a Postgres database full of data. And I made several changes to my Django app models. mange.py makemigrations worked fine and created the migration files. But manage.py migrate execute only one file. And when I launch it again it doesn’t execute the rest as if they are already applied.

I deleted the migration files that were not applied and did another makemigration but it says no changes detected.

Any ideas how to reflect the models changes on the database without losing the data ?

Thanks

Marouan
  • 56
  • 1

1 Answers1

0

Django keeps track of which migrations it has applied already, so when you run the migrate command it will execute only the migrations that Django thinks that are missing.

I deleted the migration files that were not applied and did another makemigration but it says no changes detected.

This was a bad idea, it will make your migrations inconsistent.

If you want to go back in time, instead of deleting migrations, the proper way to do this is by reverting migrations. You can use the same migrate command and specify to which migration point you want your database model to be.

Check this answer for further information about reverting migrations; django revert last migration

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
bkupfer
  • 124
  • 11