Skip to content

Bug: Migration 0006_mariadb_uuid_conversion references non-existent uuid columns in StudentItem and Score models #335

@cmersinli

Description

@cmersinli

Description

Migration 0006_mariadb_uuid_conversion (added in v3.12.1 via PR #321) attempts to modify uuid columns in three tables, but two of those tables don't have uuid columns:

The Problem

The migration executes these SQL statements on MariaDB:

ALTER TABLE submissions_submission MODIFY uuid uuid NOT NULL    -- ✅ This column EXISTS
ALTER TABLE submissions_studentitem MODIFY uuid uuid NOT NULL   -- ❌ This column does NOT exist
ALTER TABLE submissions_score MODIFY uuid uuid NOT NULL         -- ❌ This column does NOT exist

Evidence from models.py

Looking at submissions/models.py, only these models have UUID fields:

Model Has uuid field?
Submission ✅ Yes - line 315: uuid = models.UUIDField(...)
TeamSubmission ✅ Yes - line 128: uuid = models.UUIDField(...)
SubmissionFile ✅ Yes - line 753: uuid = models.UUIDField(...)
StudentItem No - only has student_id, course_id, item_id, item_type
Score No - only has foreign keys and score fields

Error Message

When running migrations on a fresh Open edX Ulmo installation with MariaDB:

django.db.utils.OperationalError: (1054, "Unknown column 'uuid' in 'submissions_studentitem'")
  Applying submissions.0006_mariadb_uuid_conversion...

Environment

  • Open edX: Ulmo (December 2025)
  • Tutor: 21.x
  • edx-submissions: 3.12.1
  • Database: MariaDB 10.11.x
  • Django: 5.x

Suggested Fix

The migration should only modify submissions_submission table, since that's the only table with a uuid column that needs conversion:

def apply_mariadb_migration(apps, schema_editor):
    # ... MariaDB check code ...
    
    with connection.cursor() as cursor:
        # Only Submission model has uuid field
        cursor.execute(
            "ALTER TABLE submissions_submission "
            "MODIFY uuid uuid NOT NULL"
        )
        # Remove StudentItem and Score - they don't have uuid columns

Workaround

For anyone encountering this issue, you can fake the migration:

./manage.py lms migrate submissions 0006_mariadb_uuid_conversion --fake

This is safe because:

  1. submissions_submission.uuid is already created as native uuid type with Django 5
  2. StudentItem and Score don't have uuid columns in the model definition

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions