# Generated by Django 3.1.6 on 2021-07-11 04:33

from django.db import migrations, models


def set_quantity_default(apps, schema_editor):
    Purchase = apps.get_model('auction', 'Purchase')
    for purchase in Purchase.objects.all():
        if not purchase.quantity:
            purchase.quantity = 1
            purchase.save()
        try:
            q = int(purchase.quantity)
        except ValueError as e:
            print(f'Unable to convert "{purchase.quantity}" to type int')
            raise e


class Migration(migrations.Migration):

    dependencies = [
        ('auction', '0008_auto_20190712_1659'),
    ]

    operations = [
        migrations.RunPython(set_quantity_default),
        migrations.AlterField(
            model_name='purchase',
            name='quantity',
            field=models.SmallIntegerField(default=1),
        ),
    ]

