#34250: Duplicate model names in M2M relationship causes RenameModel migration
failure
-----------------------------+------------------------------------
     Reporter:  Zac Miller   |                    Owner:  Bhuvnesh
         Type:  Bug          |                   Status:  assigned
    Component:  Migrations   |                  Version:  4.1
     Severity:  Normal       |               Resolution:
     Keywords:  RenameModel  |             Triage Stage:  Accepted
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by Bhuvnesh):

 Thanks zac! I did some digging in the code and found out that even though
 the field names are from/to_incident , they are referring to the correct
 models:
 {{{
 CREATE TABLE "vault_incident" ("id" integer NOT NULL PRIMARY KEY
 AUTOINCREMENT, "name" varchar(10) NOT NULL);
 CREATE TABLE "vault_incident_incidents" ("id" integer NOT NULL PRIMARY KEY
 AUTOINCREMENT, "from_incident_id" bigint NOT NULL REFERENCES
 "vault_incident" ("id") DEFERRABLE INITIALLY DEFERRED, "to_incident_id"
 bigint NOT NULL REFERENCE
 S "incidents_incident" ("id") DEFERRABLE INITIALLY DEFERRED);
 }}}

 The problem is caused in renaming fields of m2m model
 
[https://github.com/django/django/blob/main/django/db/models/fields/related.py#L1258
 here.]

 One proposed solution can be checking app names + model name together and
 if model names are same but apps are different the name of fields can be
 (like in above case) {{{incident_id}}} and {{{incidents_incident_id}}}.

 Feel free to share if anyone has a better solution. Thanks!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34250#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/01070185af2c7dce-ed993823-dcf8-4b59-af4c-2c7e24bc910a-000000%40eu-central-1.amazonses.com.

Reply via email to