Skip to content

Commit fda1b2e

Browse files
authored
Update migrate_edx_data command to set edx_enrolled and edx_emails_subscription (#3310)
1 parent 6f1193a commit fda1b2e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

courses/management/commands/migrate_edx_data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ def _bulk_create_enrollments(rows, batch_size):
364364
user_id=row["user_mitxonline_id"],
365365
run_id=row["courserun_id"],
366366
enrollment_mode=row["courserunenrollment_enrollment_mode"],
367+
edx_enrolled=True,
368+
edx_emails_subscription=False,
367369
active=True,
368370
)
369371
for row in rows
@@ -372,7 +374,11 @@ def _bulk_create_enrollments(rows, batch_size):
372374
return 0
373375

374376
CourseRunEnrollment.objects.bulk_create(
375-
new_enrollment_objects, batch_size=batch_size, ignore_conflicts=True
377+
new_enrollment_objects,
378+
batch_size=batch_size,
379+
update_conflicts=True,
380+
update_fields=["edx_enrolled", "edx_emails_subscription"],
381+
unique_fields=["user_id", "run_id"],
376382
)
377383
return len(new_enrollment_objects)
378384

0 commit comments

Comments
 (0)