#26149: Invalid migration generated when using order_with_respect_to and a
unique_together constraint
-----------------------------+------------------------------------
     Reporter:  Richard Xia  |                    Owner:  (none)
         Type:  Bug          |                   Status:  new
    Component:  Migrations   |                  Version:  1.9
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  1
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------
Comment (by amir jamshidi):

 I guess this bug don't exist no more. As I checked your sample code and
 migration done without Exception.

 your code sample: just `on_delete` added to dependancy.
 {{{

 class Bar(models.Model):
     pass


 class Foo(models.Model):
     class Meta:
         order_with_respect_to = 'bar'
         unique_together = ('bar', '_order')

     bar = models.ForeignKey(Bar, on_delete=models.CASCADE)

 }}}

 below is the migration generated:


 {{{
 class Migration(migrations.Migration):

     initial = True

     dependencies = []

     operations = [
         migrations.CreateModel(
             name="Bar",
             fields=[
                 (
                     "id",
                     models.BigAutoField(
                         auto_created=True,
                         primary_key=True,
                         serialize=False,
                         verbose_name="ID",
                     ),
                 ),
             ],
         ),
         migrations.CreateModel(
             name="Foo",
             fields=[
                 (
                     "id",
                     models.BigAutoField(
                         auto_created=True,
                         primary_key=True,
                         serialize=False,
                         verbose_name="ID",
                     ),
                 ),
                 (
                     "bar",
                     models.ForeignKey(
                         on_delete=django.db.models.deletion.CASCADE,
 to="myapp.bar"
                     ),
                 ),
             ],
             options={
                 "order_with_respect_to": "bar",
                 "unique_together": {("bar", "_order")},
             },
         ),
     ]
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/26149#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019a246ae2f9-bf4b924b-ac4f-4fa1-bbf9-075e4d9d6d1a-000000%40eu-central-1.amazonses.com.

Reply via email to