From 13d80897885e772476732d662a62308b60de3681 Mon Sep 17 00:00:00 2001 From: Christoph Buelter Date: Thu, 13 Nov 2025 13:25:20 +0100 Subject: [PATCH 1/4] Updated 5.0 release notes about MariaDB UUIDField migration (#33507). --- docs/releases/5.0.txt | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index de6d67284a..a23ffe5275 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -529,7 +529,34 @@ Should become:: uuid = Char32UUIDField(primary_key=True, default=uuid.uuid4) Running the :djadmin:`makemigrations` command will generate a migration -containing a no-op ``AlterField`` operation. +containing a no-op ``AlterField`` operation. Since any new ``UUIDField`` +would use a ``UUID`` column, the ``Char32UUIDField`` should be used +instead, when mixing column types is not desired. + +---- + +Alternatively, existing ``UUIDField`` columns could be altered in the +database to use a ``UUID`` column, by running a ``RunSQL`` operation in +a data migration:: + + class Migration(migrations.Migration): + ... + operations = [ + migrations.RunSQL( + sql=""" + ALTER TABLE my_app_model1 MODIFY my_uuid_field1 UUID NOT NULL; + ALTER TABLE my_app_model2 MODIFY my_uuid_field2 UUID NOT NULL; + """, + ) + ] + +This would avoid potentially mixing the old and new column types and +needs no additional consideration on new fields, once migrated. + +Please note that for larger tables or when ``UUIDFields`` are used as +primary keys or in constraints, this operation could either require a +lengthy table rebuild, or even end up failing to migrate the constraints +without additional steps (see :ticket:`33507` for details). Miscellaneous ------------- From 6fb854e18370eccd5d7f0f2d54b467595b2af8af Mon Sep 17 00:00:00 2001 From: Christoph Buelter Date: Thu, 13 Nov 2025 14:34:09 +0100 Subject: [PATCH 2/4] Added elidable flag to make the migration disappear on squashmigrations. See https://github.com/django/django/pull/20091#discussion_r2523405573 --- docs/releases/5.0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index a23ffe5275..c767c257dd 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -547,6 +547,7 @@ a data migration:: ALTER TABLE my_app_model1 MODIFY my_uuid_field1 UUID NOT NULL; ALTER TABLE my_app_model2 MODIFY my_uuid_field2 UUID NOT NULL; """, + elidable=True, ) ] From f43e51490ebb419d896a46cf55f1c3e744584be0 Mon Sep 17 00:00:00 2001 From: Christoph Buelter Date: Thu, 13 Nov 2025 14:57:08 +0100 Subject: [PATCH 3/4] Rephrased remarks about mixing field classes/column types for clarity. See https://github.com/django/django/pull/20091#discussion_r2523424284 --- docs/releases/5.0.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index c767c257dd..310f6cb218 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -529,9 +529,10 @@ Should become:: uuid = Char32UUIDField(primary_key=True, default=uuid.uuid4) Running the :djadmin:`makemigrations` command will generate a migration -containing a no-op ``AlterField`` operation. Since any new ``UUIDField`` -would use a ``UUID`` column, the ``Char32UUIDField`` should be used -instead, when mixing column types is not desired. +containing a no-op ``AlterField`` operation. By default, new +``UUIDField`` instances will use the ``UUID`` column type: To ensure +consistency with existing fields, use ``Char32UUIDField`` instead for +new fields that should have the same column type. ---- @@ -551,8 +552,8 @@ a data migration:: ) ] -This would avoid potentially mixing the old and new column types and -needs no additional consideration on new fields, once migrated. +Once migrated, this would need no additional consideration when adding +new ``UUIDField`` instances. Please note that for larger tables or when ``UUIDFields`` are used as primary keys or in constraints, this operation could either require a From d8d254e559a6823873e0901c189c696d0761976c Mon Sep 17 00:00:00 2001 From: Christoph Buelter Date: Fri, 14 Nov 2025 09:34:21 +0100 Subject: [PATCH 4/4] Clarified consistency statement. See https://github.com/django/django/pull/20091#discussion_r2524727369 --- docs/releases/5.0.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index 310f6cb218..6248bb8ada 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -530,9 +530,9 @@ Should become:: Running the :djadmin:`makemigrations` command will generate a migration containing a no-op ``AlterField`` operation. By default, new -``UUIDField`` instances will use the ``UUID`` column type: To ensure -consistency with existing fields, use ``Char32UUIDField`` instead for -new fields that should have the same column type. +``UUIDField`` instances will use the ``UUID`` column type. If a +``CHAR(32)`` column is needed, for example if you want to ensure +consistency with existing columns, use a ``Char32UUIDField``. ----