#30526: migration to UUID id field doesn't properly convert integers (SQLite).
------------------------------+--------------------------------------
Reporter: Martin Baker | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: invalid
Keywords: UUID | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by felixxm):
* status: new => closed
* version: 2.2 => master
* resolution: => invalid
Comment:
Thanks for this report, however changing column data type is always a
sensitive operation and you need to be aware of database caveats. SQLite
doesn't have a native `UUID` data type, so Django handles it as a
`char(32)`. Altering data type from `integer` to `char` is possible with
auto-conversion that's why you didn't get any issue when running this
migration. I don't think that there is much that Django can do here.
To fix existing data you can add
[https://docs.djangoproject.com/en/stable/topics/migrations/#data-
migrations custom data migration] and use Python's
`uuid.UUID(int=existing_pk)` to convert data from `int` to `UUID`.
--
Ticket URL: <https://code.djangoproject.com/ticket/30526#comment:2>
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/065.58e0341c5c8b11187a1570f8ce9e0200%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.