#25253: MySQL migrations drop & recreate constraints unnecessarily when changing
attributes that don't affect the schema
--------------------------------------+------------------------------------
     Reporter:  trecouvr              |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Migrations            |                  Version:  1.8
     Severity:  Normal                |               Resolution:
     Keywords:  migrations m2m mysql  |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by piquadrat):

 For what it's worth, I'm also seeing this on PostgreSQL 9.1, Django 1.9.5
 and psycopg2 2.6.1. Specifically, adding an `on_delete` argument to a
 `ForeignKey` (but I was also able to reproduce it with just adding
 `blank=True`) and then running `sqlmigrate` on the generated migration
 results in this output:

 {{{
 BEGIN;
 --
 -- Alter field last_occurrence on event
 --
 ALTER TABLE "event_event" DROP CONSTRAINT
 "last_occurrence_id_refs_id_9b97c921";
 ALTER TABLE "event_event" ADD CONSTRAINT
 "event_event_last_occurrence_id_a6d9e0d9_fk_event_instance_id" FOREIGN KEY
 ("last_occurrence_id") REFERENCES "event_instance" ("id") DEFERRABLE
 INITIALLY DEFERRED;

 COMMIT;
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25253#comment:9>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.57ccd7a46f20fd0adf1ba1eb6472c21d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to