# Generated by Django 5.2.3 on 2025-07-07 15:20
from django.db import migrations
from tqdm import tqdm

from edc_pharmacy.models import Confirmation, Stock


def update_confirm(apps, schema_editor):
    qs = Stock.objects.filter(confirmed=True)
    total = qs.count()
    for stock in tqdm(qs, total=total):
        stock.confirmation, _ = Confirmation.objects.get_or_create(
            stock=stock,
            confirmed_by=stock.confirmed_by,
            confirmed_datetime=stock.confirmed_datetime,
        )


class Migration(migrations.Migration):

    dependencies = [
        ("edc_pharmacy", "0081_historicalconfirmation_confirmation"),
    ]

    operations = [migrations.RunPython(update_confirm)]
