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

Comment (by Matthias Dellweg):

 Thanks for you answer, Mariusz.

 I do not think that this solves the problem. Yes the migration was
 handcrafted (well heavily modified), but autogenerating it was impossible
 without providing a default value for what is supposed to be the new
 primary key of the model.
 So with actual ojects of that Child model, what you need to do is:
 1. Add the new secondbase_ptr (as null and not and index)
 2. Migrate all associated objects from FirstBase to SecondBase and make
 secondbase_ptr reference them (This is where RunPython comes to the play)
 3. Remove the firstbase_ptr (to make place for another primary key)
 4. Alter secondbase_ptr to not-null and being the primary key.

 My best way to resolve this results in the question: Can i call AlterField
 in a way to turn the primary key into a common field? Or is there another
 way to pivot the primary key?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32634#comment:4>
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/066.028ad0ab6d4d1011fd006ca56ed89c15%40djangoproject.com.

Reply via email to