<reponame>2600box/harvest
# Generated by Django 2.1.7 on 2019-03-26 16:46

from django.db import migrations, models, transaction

from Harvest.utils import qs_chunks


def encode_all_raw_responses(apps, schema_editor):
    TorrentInfo = apps.get_model('torrents', 'TorrentInfo')
    for batch in qs_chunks(TorrentInfo.objects.all(), 1000):
        with transaction.atomic():
            for ti in batch:
                ti.raw_response_binary = ti.raw_response.encode()
                ti.save(update_fields=('raw_response_binary',))


class Migration(migrations.Migration):
    dependencies = [
        ('torrents', '0021_auto_20190322_1030'),
    ]

    operations = [
        migrations.AddField(
            model_name='torrentinfo',
            name='raw_response_binary',
            field=models.BinaryField(default=b''),
            preserve_default=False,
        ),
        migrations.RunPython(encode_all_raw_responses, migrations.RunPython.noop, elidable=True),
    ]

# Generated by Django 2.1.7 on 2019-03-26 16:46

from django.db import migrations, models, transaction

from Harvest.utils import qs_chunks


def encode_all_raw_responses(apps, schema_editor):
    TorrentInfo = apps.get_model('torrents', 'TorrentInfo')
    for batch in qs_chunks(TorrentInfo.objects.all(), 1000):
        with transaction.atomic():
            for ti in batch:
                ti.raw_response_binary = ti.raw_response.encode()
                ti.save(update_fields=('raw_response_binary',))


class Migration(migrations.Migration):
    dependencies = [
        ('torrents', '0021_auto_20190322_1030'),
    ]

    operations = [
        migrations.AddField(
            model_name='torrentinfo',
            name='raw_response_binary',
            field=models.BinaryField(default=b''),
            preserve_default=False,
        ),
        migrations.RunPython(encode_all_raw_responses, migrations.RunPython.noop, elidable=True),
    ]
# Generated by Django 2.1.7 on 2019-03-26 16:46