@@ -187,7 +187,7 @@ def migrate_legacy_course_roles_to_authz(course_access_role_model, course_id_lis
187187 - user: subject
188188 - role: role
189189
190- param course_access_role_model: The CourseAccessRole model to use . This is passed in because the function
190+ param course_access_role_model: It should be the CourseAccessRole model . This is passed in because the function
191191 is intended to run within a Django migration context, where direct model imports can cause issues.
192192 param course_id_list: Optional list of course IDs to filter the migration.
193193 param org_id: Optional organization ID to filter the migration.
@@ -253,6 +253,8 @@ def migrate_legacy_course_roles_to_authz(course_access_role_model, course_id_lis
253253 if delete_after_migration :
254254 # Only delete permissions that were successfully migrated to avoid data loss.
255255 course_access_role_model .objects .filter (id__in = [p .id for p in permissions_with_no_errors ]).delete ()
256+ logger .info (f"Deleted { len (permissions_with_no_errors )} legacy permissions after successful migration." )
257+ logger .info (f"Retained { len (permissions_with_errors )} legacy permissions that had errors during migration." )
256258
257259 return permissions_with_errors , permissions_with_no_errors
258260
@@ -268,9 +270,10 @@ def migrate_authz_to_legacy_course_roles(
268270 This is essentially the reverse of migrate_legacy_course_roles_to_authz and is intended
269271 for rollback purposes in case of migration issues.
270272
271- param course_access_role_model: The CourseAccessRole model to use. This is passed in because the function
273+ param course_access_role_model: It should be the CourseAccessRole model. This is passed in because the function
274+ is intended to run within a Django migration context, where direct model imports can cause issues.
275+ param user_subject_model: It should be the UserSubject model. This is passed in because the function
272276 is intended to run within a Django migration context, where direct model imports can cause issues.
273- param user_subject_model: The UserSubject model to query for users with course-related permissions.
274277 param course_id_list: Optional list of course IDs to filter the migration.
275278 param org_id: Optional organization ID to filter the migration.
276279 param delete_after_migration: Whether to unassign successfully migrated permissions
@@ -347,4 +350,8 @@ def migrate_authz_to_legacy_course_roles(
347350 role_external_key = role .external_key ,
348351 scope_external_key = scope ,
349352 )
353+ logger .info (
354+ f"Unassigned Role: { role .external_key } from User: { user_external_key } in Scope: { scope } "
355+ f" after successful rollback migration."
356+ )
350357 return roles_with_errors , roles_with_no_errors
0 commit comments