Skip to content

Commit 71a79fe

Browse files
committed
fix: Make container_type backfill reversible
This is trivial and will be helpful for devs who need to move back and forth across this migrations step for whatever reason (switching branches, resolving DB issues). Bump patch version to 0.38.1
1 parent 435f380 commit 71a79fe

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/openedx_content/migrations/0005_containertypes.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def backfill_container_types(apps, schema_editor):
2929
raise ValueError(f"container {unknown_containers[0]} is of unknown container type. Cannot apply migration.")
3030

3131

32+
def clear_container_types(apps, schema_editor):
33+
"""
34+
Drop the contents of the container_type field for the reverse migration.
35+
"""
36+
Container = apps.get_model("openedx_content", "Container")
37+
Container.objects.update(container_type=None)
38+
39+
3240
class Migration(migrations.Migration):
3341
dependencies = [
3442
("openedx_content", "0004_componenttype_constraint"),
@@ -68,7 +76,10 @@ class Migration(migrations.Migration):
6876
),
6977
),
7078
# 3. Populate the container_type column, which is currently NULL for all existing containers
71-
migrations.RunPython(backfill_container_types),
79+
migrations.RunPython(
80+
code=backfill_container_types,
81+
reverse_code=clear_container_types,
82+
),
7283
# 4. disallow NULL values from now on
7384
migrations.AlterField(
7485
model_name="container",

src/openedx_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"""
77

88
# The version for the entire repository
9-
__version__ = "0.38.0"
9+
__version__ = "0.38.1"

0 commit comments

Comments
 (0)