#24314: django 1.7 migration problem: foreign key column to an one-to-one model 
is
misidentified as "id"
--------------------------+------------------------------------------------
     Reporter:            |      Owner:  nobody
  jackxpeng               |
         Type:  Bug       |     Status:  new
    Component:            |    Version:  1.7
  Migrations              |
     Severity:  Normal    |   Keywords:  migration, one-to-one, foreign key
 Triage Stage:            |  Has patch:  0
  Unreviewed              |
Easy pickings:  0         |      UI/UX:  0
--------------------------+------------------------------------------------
 I ran into this problem trying to run manage.py test. The error I get
 looks like this:


 ALTER TABLE "quote_agentorderrejection" ADD CONSTRAINT
 "quote_agentor_agent_id_1388a6f8215473de_fk_user_agentprofile_id" FOREIGN
 KEY ("agent_id") REFERENCES "user_agentprofile" ("id") DEFERRABLE
 INITIALLY DEFERRED
 Traceback (most recent call last):
 File "/home/jack/Envs/envp1/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 66, in execute
 return self.cursor.execute(sql, params)
 psycopg2.ProgrammingError: column "id" referenced in foreign key
 constraint does not exist


 I realize this is similar to https://code.djangoproject.com/ticket/23415,
 which has been fixed. However, my case is a little different.



 {{{
 class AgentOrderRejection(models.Model):
     agent = models.ForeignKey(AgentProfile)

 }}}

 But AgentProfile itself is a one-to-one model to the user model, so its
 primary key is user_id, not id.


 {{{
     user = models.OneToOneField(USER_MODEL, primary_key=True)

 }}}

 But django 1.7's migration incorrectly identifies id as the primary key
 and looks for it in the agentprofile model and fails. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/24314>
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/052.b8af8cfbd661dc1c5cc5b36a16e5edfa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to