Wednesday, September 12, 2018

Possible bug in makemigrations

Hi all,

I found out a possible bug in the django makemigrations (i am not sure though) in django 1.11.15 (no time to test this will happen in django 2.x as well).

When deleting a field that's also in the model meta index_together the migration created by makemigrations gave an error.


In the migrations created by makemigrations

the order of migration is first to delete the field

  migrations.RemoveField(...)

and than

  migrations.AlterIndexTogether(...)


The migration did not run on my dev environment (sqllite), but after changing this order:

first alter index together and than remove filed

It worked.

so the order in makemigrations should be reversed i guess....

Did not test this on the development server, which is mysql (i used the manually changed migration on mysql right away).

but if so, i suppose this order should be changed.

My problem is solved, but might save some puzzling time in the future for others?

But not sure this si a bug, and if i should report it.....


no time to reproduce right now, but should be easy to reproduce, just make an index_together, remove one of the fields in the index together, and makemigrations....

By the way: using django 1.11.15 in this project. Not sure how this reacts in django 2.x


--
Met vriendelijke groet / With kind regards /
Med venlig Hilsen / Mit freundlichen Grüssen

Michèl van Leeuwen
Digital problem solver
michel@iamit.nl
+31 (0)6 387 58 163
www.iamit.nl
Postbus 3363 2601
DJ Delft
+31 (0)15 20 230 20

No comments:

Post a Comment