fix: refactor index_together to indexes for Django 5.2 support (IV) (#36716)

* fix: refactor index_together to indexes for Django 5.2 support

* fix: fix quality issues
This commit is contained in:
Usama Sadiq
2025-05-15 09:41:55 +05:00
committed by GitHub
parent 489dc774bb
commit cf372c20ae
2 changed files with 32 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
# Generated by Django 4.2.20 on 2025-05-14 05:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('grades', '0021_rename_persistentcoursegrade_passed_timestamp_course_id_passed_timestamp_course_id_idx_and_more'),
]
operations = [
migrations.RenameIndex(
model_name='persistentsubsectiongrade',
new_name='first_course_id_user_id_idx',
old_fields=('first_attempted', 'course_id', 'user_id'),
),
migrations.RenameIndex(
model_name='persistentsubsectiongrade',
new_name='course_id_usage_key_idx',
old_fields=('modified', 'course_id', 'usage_key'),
),
]

View File

@@ -315,9 +315,15 @@ class PersistentSubsectionGrade(TimeStampedModel):
# in a course
# (first_attempted, course_id, user_id): find all attempted subsections in a course for a user
# (first_attempted, course_id): find all attempted subsections in a course for all users
index_together = [
('modified', 'course_id', 'usage_key'),
('first_attempted', 'course_id', 'user_id')
indexes = [
models.Index(
fields=['modified', 'course_id', 'usage_key'],
name="course_id_usage_key_idx"
),
models.Index(
fields=['first_attempted', 'course_id', 'user_id'],
name="first_course_id_user_id_idx"
),
]
# primary key will need to be large for this table