Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion user_tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.dispatch import Signal

__version__ = '3.4.3'
__version__ = '3.4.4'


# This signal is emitted when a user task reaches any final state:
Expand Down
82 changes: 82 additions & 0 deletions user_tasks/migrations/0005_mariadb_uuid_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Generated migration for MariaDB UUID field conversion (Django 5.2)
"""
Migration to convert UUIDField from char(32) to uuid type for MariaDB compatibility.

This migration is necessary because Django 5 changed the behavior of UUIDField for MariaDB
databases from using CharField(32) to using a proper UUID type. This change isn't managed
automatically, so we need to generate migrations to safely convert the columns.

This migration only executes for MariaDB databases and is a no-op for other backends.

See: https://www.albertyw.com/note/django-5-mariadb-uuidfield
"""

from django.db import migrations


def apply_mariadb_migration(apps, schema_editor):
"""Apply the migration only for MariaDB databases."""
connection = schema_editor.connection

# Check if this is a MariaDB database
if connection.vendor != 'mysql':
return

# Additional check for MariaDB specifically (vs MySQL)
with connection.cursor() as cursor:
cursor.execute("SELECT VERSION()")
version = cursor.fetchone()[0]
if 'mariadb' not in version.lower():
return

# Apply the field changes for MariaDB
with connection.cursor() as cursor:
cursor.execute(
"ALTER TABLE user_tasks_usertaskstatus "
"MODIFY uuid uuid NOT NULL"
)
cursor.execute(
"ALTER TABLE user_tasks_usertaskartifact "
"MODIFY uuid uuid NOT NULL"
)


def reverse_mariadb_migration(apps, schema_editor):
"""Reverse the migration only for MariaDB databases."""
connection = schema_editor.connection

# Check if this is a MariaDB database
if connection.vendor != 'mysql':
return

# Additional check for MariaDB specifically (vs MySQL)
with connection.cursor() as cursor:
cursor.execute("SELECT VERSION()")
version = cursor.fetchone()[0]
if 'mariadb' not in version.lower():
return

# Reverse the field changes for MariaDB
with connection.cursor() as cursor:
cursor.execute(
"ALTER TABLE user_tasks_usertaskstatus "
"MODIFY uuid char(32) NOT NULL"
)
cursor.execute(
"ALTER TABLE user_tasks_usertaskartifact "
"MODIFY uuid char(32) NOT NULL"
)


class Migration(migrations.Migration):

dependencies = [
('user_tasks', '0004_url_textfield'),
]

operations = [
migrations.RunPython(
code=apply_mariadb_migration,
reverse_code=reverse_mariadb_migration,
),
]