From c43fd10339c04c6c356cbfde1f9e60fbd992c280 Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Mon, 4 Dec 2023 21:32:40 +0000 Subject: [PATCH] feat: remove old microbachelor's coaching external IDs The microbachelor coaching facility has been deprecated and the external IDs are no longer supported. Remove existing ones from the DB. FIXES: APER-2941 --- .../0007_remove_mbcoaching_extids.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 openedx/core/djangoapps/external_user_ids/migrations/0007_remove_mbcoaching_extids.py diff --git a/openedx/core/djangoapps/external_user_ids/migrations/0007_remove_mbcoaching_extids.py b/openedx/core/djangoapps/external_user_ids/migrations/0007_remove_mbcoaching_extids.py new file mode 100644 index 0000000000..f9119f55e5 --- /dev/null +++ b/openedx/core/djangoapps/external_user_ids/migrations/0007_remove_mbcoaching_extids.py @@ -0,0 +1,26 @@ +# Generated by Django 3.2.23 on 2023-12-04 18:48 +"""Deletes instances of deprecated mb_coaching external ID type""" + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("external_user_ids", "0006_auto_20230808_0944"), + ] + + mb_coaching_type_name = "mb_coaching" + + def delete_ids(apps, schema_editor): + # The + ExternalIdType = apps.get_model("external_user_ids", "ExternalIdType") + mb_coaching_type_id = ExternalIdType.objects.get( + name=Migration.mb_coaching_type_name + ).id + + ExternalId = apps.get_model("external_user_ids", "ExternalId") + ExternalId.objects.filter(external_id_type=mb_coaching_type_id).delete() + + operations = [ + migrations.RunPython(delete_ids, reverse_code=migrations.RunPython.noop) + ]