Possible bug in makemigrations

25 views
Skip to first unread message

Michel van Leeuwen

unread,
Sep 12, 2018, 6:29:30 AM9/12/18
to django...@googlegroups.com

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
mic...@iamit.nl
+31 (0)6 387 58 163
www.iamit.nl
Postbus 3363 2601
DJ Delft
+31 (0)15 20 230 20

Simon Charette

unread,
Sep 12, 2018, 8:56:48 AM9/12/18
to Django users
Hello Michèl,

I'm pretty sure you hit #28862[0] which should be fixed in Django 2.2.

Here's the PR resolving it if you're curious about it[1].

Cheers,

Reply all
Reply to author
Forward
0 new messages