in pulseapi/profiles/migrations/0018_replace_creators_with_entrycreators.py [0:0]
def create_entrycreators_for_orderedcreatorrecords(apps, schema_editor):
OrderedCreatorRecord = apps.get_model('creators', 'OrderedCreatorRecord')
EntryCreator = apps.get_model('creators', 'EntryCreator')
for ocr in OrderedCreatorRecord.objects.all():
try:
with transaction.atomic():
EntryCreator.objects.create(
entry=ocr.entry,
profile=ocr.creator.profile
)
except IntegrityError:
# We ignore duplicate key violations so that only single
# relations exist between entries and profiles.
# This exception might be thrown if there are discrepancies
# in the old OrderedCreatorRecord model data where duplicate
# (entry_id, profile_id) key combinations were created.
pass