"""G3 — bind LogFrame to a finance Budget (nullable).

PROTECT: deleting a Budget that's referenced by a LogFrame would orphan the
budget-variance section without warning. Force the user to detach first.
"""
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("mel_indicators", "0006_g11_historical_data_point"),
        ("rims_finance", "0007_disbursement_payment_receipts"),
    ]

    operations = [
        migrations.AddField(
            model_name="logframe",
            name="finance_budget",
            field=models.ForeignKey(
                blank=True,
                help_text=(
                    "G3 — bind this log frame to a finance Budget to enable "
                    "budget-vs-expenditure variance reporting in the report builder."
                ),
                null=True,
                on_delete=models.deletion.PROTECT,
                related_name="mel_logframes",
                to="rims_finance.budget",
            ),
        ),
        migrations.AddField(
            model_name="historicallogframe",
            name="finance_budget",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                help_text=(
                    "G3 — bind this log frame to a finance Budget to enable "
                    "budget-vs-expenditure variance reporting in the report builder."
                ),
                null=True,
                on_delete=models.deletion.DO_NOTHING,
                related_name="+",
                to="rims_finance.budget",
            ),
        ),
    ]
