Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/openedx_content/migrations/0005_containertypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def backfill_container_types(apps, schema_editor):
raise ValueError(f"container {unknown_containers[0]} is of unknown container type. Cannot apply migration.")


def clear_container_types(apps, schema_editor):
"""
Drop the contents of the container_type field for the reverse migration.
"""
Container = apps.get_model("openedx_content", "Container")
Container.objects.update(container_type=None)


class Migration(migrations.Migration):
dependencies = [
("openedx_content", "0004_componenttype_constraint"),
Expand Down Expand Up @@ -68,7 +76,10 @@ class Migration(migrations.Migration):
),
),
# 3. Populate the container_type column, which is currently NULL for all existing containers
migrations.RunPython(backfill_container_types),
migrations.RunPython(
code=backfill_container_types,
reverse_code=clear_container_types,
),
# 4. disallow NULL values from now on
migrations.AlterField(
model_name="container",
Expand Down
2 changes: 1 addition & 1 deletion src/openedx_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"""

# The version for the entire repository
__version__ = "0.38.0"
__version__ = "0.38.1"