Merge pull request #36823 from openedx/iamsobanjaved/fix-csmh-index-migration
[DO NOT MERGE – Needs Staging Verification] fix!: Update the migration to have one Index on student_module_id
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Generated by Django 4.2.20 on 2025-05-15 03:30
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@@ -10,9 +11,26 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameIndex(
|
||||
migrations.AlterField(
|
||||
model_name='studentmodulehistoryextended',
|
||||
new_name='student_module_idx',
|
||||
old_fields=('student_module',),
|
||||
name='student_module',
|
||||
field=models.ForeignKey(db_constraint=False, db_index=False, on_delete=django.db.models.deletion.DO_NOTHING, to='courseware.studentmodule'),
|
||||
),
|
||||
# This SeparateDatabaseAndState operation updates the state to match the model.
|
||||
# database_operations is left empty because the indexes were already dropped
|
||||
# by the previous operation in the database.
|
||||
migrations.SeparateDatabaseAndState(
|
||||
database_operations=[],
|
||||
state_operations=[
|
||||
migrations.AlterIndexTogether(
|
||||
name='studentmodulehistoryextended',
|
||||
index_together=set(),
|
||||
),
|
||||
],
|
||||
),
|
||||
# Adds back the index on 'student_module' to ensure there is a single index on this field.
|
||||
migrations.AddIndex(
|
||||
model_name='studentmodulehistoryextended',
|
||||
index=models.Index(fields=['student_module'], name='student_module_idx'),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -42,7 +42,7 @@ class StudentModuleHistoryExtended(BaseStudentModuleHistory):
|
||||
|
||||
id = UnsignedBigIntAutoField(primary_key=True) # pylint: disable=invalid-name
|
||||
|
||||
student_module = models.ForeignKey(StudentModule, db_index=True, db_constraint=False, on_delete=models.DO_NOTHING)
|
||||
student_module = models.ForeignKey(StudentModule, db_index=False, db_constraint=False, on_delete=models.DO_NOTHING)
|
||||
|
||||
@receiver(post_save, sender=StudentModule)
|
||||
def save_history(sender, instance, **kwargs): # pylint: disable=no-self-argument, unused-argument
|
||||
|
||||
Reference in New Issue
Block a user