#34151: Adding explicit primary key with different type doesn't update related
ManyToManyFields.
-------------------------------------+-------------------------------------
     Reporter:  STANISLAV LEPEKHOV   |                    Owner:  Bhuvnesh
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  4.1
     Severity:  Normal               |               Resolution:
     Keywords:  migrations pk uuid   |             Triage Stage:  Accepted
  relation                           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Bhuvnesh):

 The migration generated for this contains removing the old pk and adding
 new pk :
 {{{
 class Migration(migrations.Migration):

     dependencies = [
         ("ticket_34151", "0001_initial"),
     ]

     operations = [
         migrations.RemoveField(
             model_name="place",
             name="id",
         ),
         migrations.RemoveField(
             model_name="storechain",
             name="id",
         ),
         migrations.AddField(
             model_name="place",
             name="uid",
             field=models.UUIDField(
                 default=uuid.uuid4,
                 editable=False,
                 primary_key=True,
                 serialize=False,
                 unique=True,
             ),
         ),
         migrations.AddField(
             model_name="storechain",
             name="uid",
             field=models.UUIDField(
                 default=uuid.uuid4,
                 editable=False,
                 primary_key=True,
                 serialize=False,
                 unique=True,
             ),
         ),
     ]
 }}}
 but on some databases (mysql, postgres) we cannot delete a pk of a model
 which is referenced by other.
 I tried to implement a
 solution([https://github.com/django/django/pull/16325 draft PR] ) which is
 working fine for sqlite3 but throws the following error on some dbs
 (mysql, postgres) during the RemoveField operation:
 {{{
 (1829, "Cannot drop column 'id': needed in a foreign key constraint
 'ticket_34151_storech_placespk_id_ca7ce831_fk_ticket_34' of table
 'ticket_34151_storechain'")
 }}}
 This made me think if it is really possible to add a new pk to a
 referenced model for dbs like mysql and postgres?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34151#comment:10>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184c3a6f4b7-c927ca03-970c-46ee-a5ae-93fc2a284090-000000%40eu-central-1.amazonses.com.

Reply via email to