#32634: AlterField drops contraints in the wrong order when performed as reverse
migration
--------------------------------------------+------------------------
               Reporter:  Matthias Dellweg  |          Owner:  nobody
                   Type:  Bug               |         Status:  new
              Component:  Migrations        |        Version:  2.2
               Severity:  Normal            |       Keywords:
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  0
                  UI/UX:  0                 |
--------------------------------------------+------------------------
 The following migration step

 {{{
 migrations.AlterField(
             model_name='filedistribution',
             name='distribution_ptr',
             field=models.OneToOneField(auto_created=True,
 on_delete=django.db.models.deletion.CASCADE,
                                        parent_link=True, primary_key=True,
 related_name='file_filedistribution', serialize=False,
                                        to='core.Distribution'),
             preserve_default=False,
         ),
 }}}

 in reverse mode produces

 {{{
 ALTER TABLE "file_filedistribution" ALTER COLUMN "distribution_ptr_id"
 DROP NOT NULL;
 ALTER TABLE "file_filedistribution" DROP CONSTRAINT
 "file_filedistribution_distribution_ptr_id_5ce5564b_pk";
 }}}

 leading to an error

 {{{
 django.db.utils.ProgrammingError: column "distribution_ptr_id" is in a
 primary key
 }}}

 Switching the order of the statements enabled me execute the SQL just
 fine.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32634>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/051.be2ea65957073b5211b01d54dc8ee8fa%40djangoproject.com.

Reply via email to