[Django] #33507: Use native UUID data type on MariaDB 10.7+

82 views
Skip to first unread message

Django

unread,
Feb 10, 2022, 3:48:27 AM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz | Owner: nobody
Felisiak |
Type: New | Status: new
feature |
Component: Database | Version: 4.0
layer (models, ORM) |
Severity: Normal | Keywords: mariadb
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
MariaDB 10.7 introduces `UUID` data type, see [https://mariadb.com/kb/en
/uuid-data-type/ docs] and [https://mariadb.org/10-7-preview-feature-uuid-
data-type/ blog post]. We should corrected the `has_native_uuid_field`
feature flag and use it instead of `char(32)`.

--
Ticket URL: <https://code.djangoproject.com/ticket/33507>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 10, 2022, 4:32:53 AM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Mariusz Felisiak:

Old description:

> MariaDB 10.7 introduces `UUID` data type, see [https://mariadb.com/kb/en
> /uuid-data-type/ docs] and [https://mariadb.org/10-7-preview-feature-

> uuid-data-type/ blog post]. We should corrected the


> `has_native_uuid_field` feature flag and use it instead of `char(32)`.

New description:

MariaDB 10.7 introduces `UUID` data type, see [https://mariadb.com/kb/en
/uuid-data-type/ docs] and [https://mariadb.org/10-7-preview-feature-uuid-
data-type/ blog post]. We should corrected the `has_native_uuid_field`

feature flag and use `uuid` instead of `char(32)`.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:1>

Django

unread,
Feb 10, 2022, 5:49:13 AM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Old description:

> MariaDB 10.7 introduces `UUID` data type, see [https://mariadb.com/kb/en
> /uuid-data-type/ docs] and [https://mariadb.org/10-7-preview-feature-

> uuid-data-type/ blog post]. We should corrected the
> `has_native_uuid_field` feature flag and use `uuid` instead of
> `char(32)`.

New description:

MariaDB 10.7 introduces `UUID` data type, see [https://mariadb.com/kb/en
/uuid-data-type/ docs] and [https://mariadb.org/10-7-preview-feature-uuid-

data-type/ blog post]. We should correct the `has_native_uuid_field`
feature flag and use `uuid` instead of `char(32)`.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:2>

Django

unread,
Feb 10, 2022, 10:21:07 AM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

Small note that we should make sure that changing this flag won't break
installs with `UUIDField` backend by `char(32)` columns as it might be
impractical for large installs to rebuild their whole table primary keys
otherwise.

If we don't document a clear upgrade path I foresee a few reports when
users attempt to add a `ForeignKey` referencing a model with a `UUIDField`
primary key that is backend by a `char(32)` and hit a MariaDB error
telling them that a foreign constraint cannot be created from a `uuid` to
a `char(32)` column.

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:3>

Django

unread,
Feb 10, 2022, 2:34:19 PM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:3 Simon Charette]:


> Small note that we should make sure that changing this flag won't break
installs with `UUIDField` backend by `char(32)` columns as it might be
impractical for large installs to rebuild their whole table primary keys
otherwise.
>
> If we don't document a clear upgrade path I foresee a few reports when
users attempt to add a `ForeignKey` referencing a model with a `UUIDField`

primary key that is backed by a `char(32)` and hit a MariaDB error telling


them that a foreign constraint cannot be created from a `uuid` to a
`char(32)` column.

According to the [https://mariadb.org/10-7-preview-feature-uuid-data-type/
blog post], it should be possible to change a data type without manual
data conversion:

> ''With these basic conversion rules, you can migrate from your existing
CHAR/VARCHAR/TEXT hexadecimal text or BINARY/VARBINARY/BLOB encoded to
UUID using:''
> {{{
> CREATE TABLE t1 (id BINARY(16));
> ALTER TABLE t1 MODIFY COLUMN id UUID;
> }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:4>

Django

unread,
Feb 10, 2022, 3:21:06 PM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adam Johnson):

That `ALTER TABLE` still requires a table rebuild, which is impractical or
impossible for large installations’ PK's. But maybe the "upgrade path"
there would be "create a field subclass always backed by `char(32)`".

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:5>

Django

unread,
Feb 10, 2022, 4:09:07 PM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

> With these basic conversion rules, you can migrate from your existing
CHAR/VARCHAR/TEXT hexadecimal text or BINARY/VARBINARY/BLOB encoded to
UUID using:

Unfortunately, this statement doesn't account for the fact that UUIDs are
often used as primary keys and thus referenced by other tables where this
approach simply won't work as you get in a chicken-egg problem with
foreign references. To perform this properly a manual dropping of
references, followed by type alterations of all tables involved, and final
step to recreate constraints is required which possibly will require table
rebuilds as Adam pointed out.

> But maybe the "upgrade path" there would be "create a field subclass
always backed by char(32)".

That seems like the most suitable upgrade path. It will likely require
documenting that all the generated migration operations should be wrapped
in `SeparateDatabaseAndState` unless we adapt the schema editor to avoid
`ALTER` when the generated SQL column of `from_field` and `to_field`
remains the same.

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:6>

Django

unread,
Feb 10, 2022, 5:17:14 PM2/10/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adam Johnson):

> unless we adapt the schema editor to avoid `ALTER` when the generated
SQL column of `from_field` and `to_field` remains the same.

This sounds like generally a good idea any way!

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:7>

Django

unread,
Feb 11, 2022, 12:10:39 AM2/11/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Agreed, this can be tricky. I'd really like to come up with a doable
pattern that could be used in the future, because other emulated fields
may be implemented in the databases.

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:8>

Django

unread,
Mar 14, 2022, 4:10:35 AM3/14/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Mohammad
| Ali Mehdizadeh
Type: New feature | Status: assigned

Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mohammad Ali Mehdizadeh):

* owner: nobody => Mohammad Ali Mehdizadeh
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:9>

Django

unread,
Apr 1, 2022, 3:32:46 AM4/1/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: (none)

Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mohammad Ali Mehdizadeh):

* owner: Mohammad Ali Mehdizadeh => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:10>

Django

unread,
Apr 21, 2022, 4:48:22 AM4/21/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal

Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* owner: nobody => raydeal


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:9>

Django

unread,
May 1, 2022, 12:05:43 PM5/1/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by raydeal):

MariaDB 10.7 seems to be a short-term maintenance release
https://mariadb.org/about/#maintenance-policy, and django 4.1 still
supports version 10.3

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:10>

Django

unread,
Oct 19, 2022, 10:00:54 AM10/19/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:11>

Django

unread,
Oct 24, 2022, 5:05:35 AM10/24/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:12>

Django

unread,
Nov 26, 2022, 1:53:39 PM11/26/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:13>

Django

unread,
Dec 16, 2022, 5:47:23 AM12/16/22
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:7 Adam Johnson]:


> > unless we adapt the schema editor to avoid `ALTER` when the generated
SQL column of `from_field` and `to_field` remains the same.
>
> This sounds like generally a good idea any way!

Looks like it already
[https://github.com/django/django/blob/05d70fb92b72f9701bea99c809a5edd53b290de9/django/db/backends/base/schema.py#L961-L966
works]. For example, I've changed `models.CharField(max_length=50,
unique=True)` to `models.SlugField(unique=True)` on PostgreSQL and Django
didn't alter the db type:
{{{#!sql
--
-- Alter field field_2 on mytestmodel
--
-- (no-op)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:14>

Django

unread,
Feb 28, 2023, 3:58:08 AM2/28/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:15>

Django

unread,
Jun 10, 2023, 4:07:17 PM6/10/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* needs_better_patch: 1 => 0

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:16>

Django

unread,
Jun 22, 2023, 12:10:15 AM6/22/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:17>

Django

unread,
Jul 2, 2023, 8:40:51 AM7/2/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:18>

Django

unread,
Aug 2, 2023, 3:59:11 AM8/2/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:19>

Django

unread,
Aug 2, 2023, 1:38:00 PM8/2/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed

Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"7cd187a5ba58d7769039f487faeb9a5a2ff05540" 7cd187a]:
{{{
#!CommitTicketReference repository=""
revision="7cd187a5ba58d7769039f487faeb9a5a2ff05540"
Fixed #33507 -- Used UUID data type on MariaDB 10.7+.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:20>

Django

unread,
Aug 25, 2023, 5:24:31 AM8/25/23
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"9c37103a98d030be110eb9ba8b7ed32a47240b28" 9c37103]:
{{{
#!CommitTicketReference repository=""
revision="9c37103a98d030be110eb9ba8b7ed32a47240b28"
Refs #33507 -- Doc'd using UUID data type on MariaDB 10.7+ in UUIDField
docs.

Follow up to 7cd187a5ba58d7769039f487faeb9a5a2ff05540.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:21>

Django

unread,
Oct 8, 2025, 11:32:30 AM10/8/25
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Klaas van Schelven):

I just ran into this [https://github.com/bugsink/bugsink/issues/226 here].

Caused by not carefully reading the release notes, but quite hard to
debug.

Having actually read those notes now, I'm left to wonder:

1. what will happen with existing databases that are from a post-5.0
world? They will have been created with uuid columns. Will the suggested
migration path accidentally brake _those_?
2. the suggested path is "varchars everywhere". But my project is deployed
on many DB backends, also postgres. So the suggested solution is a
downgrade for those and or create the risk of breakage on those...

I realise these questions may be "more on me than on Django" but OTOH the
present issue seems like exactly the spot where people with such problems
would gather.
--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:22>

Django

unread,
Oct 8, 2025, 11:37:50 AM10/8/25
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Klaas van Schelven):

I also think there's another problem with this change: someone upgrading
mariadb _itself_ (to 10.7 from a lower version) would have to go through
the exact same migration instructions. These are currently undocumented,
and even if they were it is unlikely that someone would actually find them
(because one would be looking at the maria instructions, not the django
ones)
--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:23>

Django

unread,
Nov 13, 2025, 4:07:04 AM11/13/25
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Christoph Bülter):

I would like to add some thoughts about my recent experience using MariaDB
10.11 and upgrading from Django 3 to 5:

- The recommended upgrade path for UUIDFields in the docs
(https://docs.djangoproject.com/en/5.2/releases/5.0/#migrating-existing-
uuidfield-on-mariadb-10-7) currently is defining a custom
`Char32UUIDField` class and using that instead of the builtin
`models.UUIDField`, to keep using a `CHAR(32)` column type under the hood.

- This however means developers will have to remember using that custom
field, so if someone forgets and accidentally creates a new
`models.UUIDField` later on, there will be a mix of `CHAR(32)` and `UUID`
columns in the database, which is probably not ideal. I would like to
reiterate on an alternative upgrade path:

- In previous comments, valid concerns have been raised about potential
issues with large tables, table rebuilds and UUIDFields used as primary-
keys or in foreign-key relations. Our migration scenario is much simpler,
though: We have lots of UUIDFields, but the tables are relatively small
and they are not used as primary-keys or in relations.

- Instead of using that aforementioned `Char32UUIDField`, it made more
sense for us to just convert all existing `models.UUIDField` from
`CHAR(32)` to `UUID` in a Django data migration, and then use the builtin
`models.UUIDField` moving forward, so everything is based on the `UUID`
type. The data migration could look like:


{{{#!python
class Migration(migrations.Migration):
dependencies = [
("my_app", "0001_initial"),
]
operations = [
# Update UUIDFields from CHAR(32) to UUID
migrations.RunSQL(
sql="""
ALTER TABLE myapp_table1 MODIFY field1 UUID NOT NULL;
ALTER TABLE myapp_table2 MODIFY field2 UUID NOT NULL;
ALTER TABLE myapp_table3 MODIFY field3 UUID NOT NULL;
""",
)
]
}}}


I believe for our scenario this is easier to maintain longterm, since
there's nothing special to remember about and no danger of introducing
mixed types.

Would this be worth mentioning in the docs as an alternative option (aka
the first link I posted)?
--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:24>

Django

unread,
Nov 13, 2025, 10:22:41 AM11/13/25
to django-...@googlegroups.com
#33507: Use native UUID data type on MariaDB 10.7+
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: raydeal
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: mariadb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

Personally, I'd try to avoid multiple migrations paths in our release
notes, it can be confusing. Your comment in this ticket should be enough
to help users who struggle.
--
Ticket URL: <https://code.djangoproject.com/ticket/33507#comment:25>
Reply all
Reply to author
Forward
0 new messages