Hey Bill,

I added a patch for the ticket Tim already linked to. This solves the
problem for RemoveField operations, RenameField shouldn't be a
problem since the generation of AlterUniqueTogether and
AlterIndexTogether are already based on renamed fields. Tests welcome ;)

/Markus

On Mon, Oct 27, 2014 at 11:48:43AM -0700, Tim Graham wrote:
Hi Bill,

Yes, I believe this is a valid issue. I think it was reported in
https://code.djangoproject.com/ticket/23614

Tim

On Monday, October 27, 2014 12:32:10 PM UTC-4, Bill Prin wrote:

Hi all,

I wasn't sure which mailing list to put this on, so I cross-posted it with
django-core-mentorship. Apologies if this isn't the right forum.

I stumbled across an issue when removing a field from a unique_together
constraint. Specifically, when you remove a field, and remove it from the
unique_together constraint, the makemigration command creates a migration
that first removes the field, then removes the constraint. However, it puts
the operations in the wrong order which creates an error.

I've had this problem in Django 1.7, and I just checked out master 1.8
from github and reproduced the issue.

Here I am removing a field question3 from a model, as well as removing it
from the unique_together constraint (question1, question2, question3).

    operations = [
        migrations.RemoveField(
            model_name='question',
            name='question3',
        ),
        migrations.AlterUniqueTogether(
            name='question',
            unique_together=set([('question1', 'question2')]),
        )
    ]

The problem is that the field is gone when the unique together constraint
is altered, creating this problem:

django.db.models.fields.FieldDoesNotExist: Question has no field named
u'question3'

This is trivial to fix by reversing the order of the operations. I did
search the bug tracker and mailing lists and did not find the issue, but
again, apologies if I didn't look in the right place.

The reason I'm posting here instead of just submitting an issue is because
I would love to get involved in contributing to core, and this seems like a
really easy bug to get my hands dirty with. However, given that I'm not
super familiar with the project, before I dove into it I thought I would
run it by the mailing lists to verify that I'm not missing something, and
also that if I do make a pull request to fix it, it will be accepted.
Thanks for any advice!

Bill


--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/09170b1f-5ba9-40e5-be16-6f2926f4c908%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Attachment: pgpK98m7kpLay.pgp
Description: PGP signature

Reply via email to