#34151: django.db.migrations doesn't update *_id column data type in related 
table
when changing pk type of linked models.
-------------------------------------+-------------------------------------
     Reporter:  STANISLAV LEPEKHOV   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Management     |                  Version:  4.1
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  migrations pk uuid   |             Triage Stage:
  relation                           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by STANISLAV LEPEKHOV:

Old description:

> Hello!
> When i changed this models:
>
> {{{
> class StoreChain(models.Model):
>     places = models.ManyToManyField(Place, blank=True)
>
> class Place(models.Model):
>     uid = models.UUIDField(default=uuid.uuid4, editable=False,
> primary_key=True, unique=True)
> }}}
>
> to this edition (set pk with uuid type):
> {{{
> class StoreChain(models.Model):
>     uid = models.UUIDField(default=uuid.uuid4, editable=False,
> primary_key=True, unique=True)
>     places = models.ManyToManyField(Place, blank=True)
>
> class Place(models.Model):
>     uid = models.UUIDField(default=uuid.uuid4, editable=False,
> primary_key=True, unique=True)
> }}}
>
> Django creates a migration file that affects only the model tables, while
> the relationship table remains unchanged, which will cause an error,
> because the data type of the _ID fields in it also needs to be changed:
> [[Image(https://i.ibb.co/XZYjvYp/hU0HJyqF.jpg)]]

New description:

 Hello!
 When i changed this models:

 {{{
 class StoreChain(models.Model):
     places = models.ManyToManyField(Place, blank=True)

 class Place(models.Model):
     pass
 }}}

 to this edition (set pk with uuid type):
 {{{
 class StoreChain(models.Model):
     uid = models.UUIDField(default=uuid.uuid4, editable=False,
 primary_key=True, unique=True)
     places = models.ManyToManyField(Place, blank=True)

 class Place(models.Model):
     uid = models.UUIDField(default=uuid.uuid4, editable=False,
 primary_key=True, unique=True)
 }}}

 Django creates a migration file that affects only the model tables, while
 the relationship table remains unchanged, which will cause an error,
 because the data type of the _ID fields in it also needs to be changed:
 [[Image(https://i.ibb.co/XZYjvYp/hU0HJyqF.jpg)]]

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34151#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/0107018467075cc1-cec56be6-b1b1-4e07-9fa6-cf8d29de2257-000000%40eu-central-1.amazonses.com.

Reply via email to