# Generated by Django 4.1.7 on 2023-03-27 16:22

import django.db.models.deletion
from django.db import migrations, models


def delete_baskets_without_payment_method(apps, schema_editor):
    Basket = apps.get_model("purchase", "Basket")
    Basket.objects.using(schema_editor.connection.alias).filter(
        payment_method=None,
    ).delete()


class Migration(migrations.Migration):
    dependencies = [
        ("purchase", "0013_remove_basketitem_unique_product_per_basket_and_more"),
    ]

    operations = [
        # Remove baskets with no payment method
        migrations.RunPython(
            delete_baskets_without_payment_method,
            migrations.RunPython.noop,
        ),
        migrations.AlterField(
            model_name="basket",
            name="payment_method",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="baskets",
                to="purchase.paymentmethod",
                verbose_name="payment method",
            ),
        ),
    ]
