#32869: Bug while migrating a OneToOneField to ForeignKey on PostgreSQL.
-------------------------------------+-------------------------------------
     Reporter:  suhailvs             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  3.2
     Severity:  Normal               |               Resolution:
                                     |  worksforme
     Keywords:  postgres             |             Triage Stage:
  onetoonefield foreignkey           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 Thanks for the report, however, it works for me. Django drops a unique
 constraint when altering `OneToOneField` to the `ForeignKey`, e.g.
 {{{
 $ python manage.py sqlmigrate test_32869 0002

 BEGIN;
 --
 -- Alter field user on customer
 --
 SET CONSTRAINTS "test_32869_customer_user_id_794e3015_fk_auth_user_id"
 IMMEDIATE; ALTER TABLE "test_32869_customer" DROP CONSTRAINT
 "test_32869_customer_user_id_794e3015_fk_auth_user_id";
 ALTER TABLE "test_32869_customer" DROP CONSTRAINT
 "test_32869_customer_user_id_key";
 CREATE INDEX "test_32869_customer_user_id_794e3015" ON
 "test_32869_customer" ("user_id");
 ALTER TABLE "test_32869_customer" ADD CONSTRAINT
 "test_32869_customer_user_id_794e3015_fk_auth_user_id" FOREIGN KEY
 ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED;
 COMMIT;
 }}}
 (I used `test_32869` instead of `myapp`.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32869#comment:1>
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.6b73ffc65bed3581620785646b3ddcde%40djangoproject.com.

Reply via email to