#33673: PostgreSQL removes constraints when removing columns.
----------------------------+--------------------------------------
     Reporter:  George      |                    Owner:  nobody
         Type:  Bug         |                   Status:  closed
    Component:  Migrations  |                  Version:  3.2
     Severity:  Normal      |               Resolution:  needsinfo
     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 George):

 Replying to [comment:2 Mariusz Felisiak]:
 > Thanks for the report, however PostgreSQL silently drops constraints,
 not Django itself. Unfortunately when you create migrations manually you
 must be aware of database-specific behavior and handle them on your own in
 most of cases. As far as I'm aware described use case (removing column to
 add it immediately in the same migration) is really unusual and not worth
 additional complexity and a performance regression for all users. Noticing
 that constraint is missing would require inspecting db constraints which
 is always quite expensive.
 >
 > Is there any reason you cannot handle this automatically with
 `AlterField()`?

 No particular reason, no, and in this case I agree the issue is we had a
 poorly written manual migration, fault is on us. I just wanted to make
 sure this is indeed the behavior.

 Out of curiosity, does django inspect the database at all for migrations
 or is it 100% looking at the mdoel's code and comparing it with the code
 from all previous migrations?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33673#comment:3>
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/0107018089e93345-398a9395-5973-4cc9-a78f-57fedd00d641-000000%40eu-central-1.amazonses.com.

Reply via email to