From af5faf4965d9c64444a5c9e3a675090b0107df1c Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Tue, 13 May 2025 11:06:34 +0500 Subject: [PATCH] fix: refactor index_together to indexes for Django 5.2 support (#36702) --- ...passed_timestamp_course_id_idx_and_more.py | 23 +++++++++++++++++++ lms/djangoapps/grades/models.py | 6 ++--- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 lms/djangoapps/grades/migrations/0021_rename_persistentcoursegrade_passed_timestamp_course_id_passed_timestamp_course_id_idx_and_more.py diff --git a/lms/djangoapps/grades/migrations/0021_rename_persistentcoursegrade_passed_timestamp_course_id_passed_timestamp_course_id_idx_and_more.py b/lms/djangoapps/grades/migrations/0021_rename_persistentcoursegrade_passed_timestamp_course_id_passed_timestamp_course_id_idx_and_more.py new file mode 100644 index 0000000000..c75dffc063 --- /dev/null +++ b/lms/djangoapps/grades/migrations/0021_rename_persistentcoursegrade_passed_timestamp_course_id_passed_timestamp_course_id_idx_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.20 on 2025-05-12 13:39 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('grades', '0020_alter_historicalpersistentsubsectiongradeoverride_options'), + ] + + operations = [ + migrations.RenameIndex( + model_name='persistentcoursegrade', + new_name='passed_timestamp_course_id_idx', + old_fields=('passed_timestamp', 'course_id'), + ), + migrations.RenameIndex( + model_name='persistentcoursegrade', + new_name='modified_course_id_idx', + old_fields=('modified', 'course_id'), + ), + ] diff --git a/lms/djangoapps/grades/models.py b/lms/djangoapps/grades/models.py index 3d1facfdb0..f6266b9f82 100644 --- a/lms/djangoapps/grades/models.py +++ b/lms/djangoapps/grades/models.py @@ -569,9 +569,9 @@ class PersistentCourseGrade(TimeStampedModel): unique_together = [ ('course_id', 'user_id'), ] - index_together = [ - ('passed_timestamp', 'course_id'), - ('modified', 'course_id') + indexes = [ + models.Index(fields=['passed_timestamp', 'course_id'], name="passed_timestamp_course_id_idx"), + models.Index(fields=['modified', 'course_id'], name="modified_course_id_idx") ] # primary key will need to be large for this table