From 9bf0592a086a6a5158fa5b5a0f5631a26ee8f6b9 Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Mon, 12 May 2025 18:40:23 +0500 Subject: [PATCH] fix: refactor index_together to indexes for Django 5.2 support --- ...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 000000000000..c75dffc063eb --- /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 3d1facfdb0ad..f6266b9f828b 100644 --- a/lms/djangoapps/grades/models.py +++ b/lms/djangoapps/grades/models.py @@ -569,9 +569,9 @@ class Meta: 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