# Generated by Django 2.0.6 on 2018-06-19 16:57

from django.db import migrations


def generate_arxiv_ids(apps, schema_editor):
    SourceFile = apps.get_model('papers', 'SourceFile')
    for sf in SourceFile.objects.all():
        if not sf.arxiv_id:
            sf.arxiv_id = sf.file.name.rsplit('.', 1)[0]
            sf.save()


class Migration(migrations.Migration):

    dependencies = [
        ('papers', '0016_auto_20180619_1655'),
    ]

    operations = [
        migrations.RunPython(generate_arxiv_ids),
    ]

# Generated by Django 2.0.6 on 2018-06-19 16:57

from django.db import migrations


def generate_arxiv_ids(apps, schema_editor):
    SourceFile = apps.get_model('papers', 'SourceFile')
    for sf in SourceFile.objects.iterator():
        if not sf.arxiv_id:
            sf.arxiv_id = sf.file.name.rsplit('.', 1)[0]
            sf.save()


class Migration(migrations.Migration):

    dependencies = [
        ('papers', '0016_auto_20180619_1655'),
    ]

    operations = [
        migrations.RunPython(generate_arxiv_ids),
    ]

Use iterator in migration to reduce memory