# Generated by Django 3.0.1 on 2020-01-30 11:19

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


class Migration(migrations.Migration):

    dependencies = [
        ('djpaypal', '0012_billing_agreement_state'),
    ]

    operations = [
        migrations.AddField(
            model_name='billingagreement',
            name='plan_model',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='djpaypal.BillingPlan'),
        ),
        migrations.RunSQL("""
            UPDATE djpaypal_billingagreement db
            SET plan_model_id = dp."data"->'plan'->>'id'
            FROM djpaypal_preparedbillingagreement dp
            WHERE dp.executed_agreement_id = db.id;
        """)
    ]
