Skip to content
Snippets Groups Projects
Commit a68bfe28 authored by Julia Eskew's avatar Julia Eskew Committed by Julia Eskew
Browse files

fix: Use a "through" model for the ManyToManyField fields in CourseSection

and CourseSectionSequence to ensure that cascading deletes will occur to delete
the relation upon deletion of a foreign-keyed object.

This commit is phase 3 of 4 in order to ensure a smooth deploy. The phases:
1) Add separate through models for user partition groups, add fields to point to the
   separate models, and start writing to those fields as well. (COMPLETE)
2) After all models have been re-generated, switch code over to use separate through
   model fields backed by the separate through models *and* stop writing to the original
   ManyToManyField field. (COMPLETE)
3) After phase 2 is deployed smoothly, remove the original ManyToManyField fields. (This PR!)
4) After phase 3 is deployed smoothly, rename the new fields to have the same name
   as the old fields, so new_user_partition_groups -> user_partition_groups.

This PR is designed to be able to easily be rolled-back if anything goes wrong.
parent 1b0b7031
No related merge requests found
# Generated by Django 2.2.24 on 2021-07-07 16:45
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('learning_sequences', '0015_add_user_partition_group_unique_constraint'),
]
operations = [
migrations.RemoveField(
model_name='coursesection',
name='user_partition_groups',
),
migrations.RemoveField(
model_name='coursesectionsequence',
name='user_partition_groups',
),
]
......@@ -202,8 +202,6 @@ class CourseSection(CourseContentVisibilityMixin, TimeStampedModel):
# What is our position within the Course? (starts with 0)
ordering = models.PositiveIntegerField(null=False)
user_partition_groups = models.ManyToManyField(UserPartitionGroup)
new_user_partition_groups = models.ManyToManyField(
UserPartitionGroup,
db_index=True,
......@@ -266,8 +264,6 @@ class CourseSectionSequence(CourseContentVisibilityMixin, TimeStampedModel):
# sequences across 20 sections, the numbering here would be 0-199.
ordering = models.PositiveIntegerField(null=False)
user_partition_groups = models.ManyToManyField(UserPartitionGroup)
new_user_partition_groups = models.ManyToManyField(
UserPartitionGroup,
db_index=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment