# Generated by Django 3.2 on 2021-05-05 12:25

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


def add_all_career_stages_to_calls(apps, schema_editor):
    Call = apps.get_model('project_core', 'Call')
    CareerStage = apps.get_model('project_core', 'CareerStage')
    CallCareerStage = apps.get_model('project_core', 'CallCareerStage')

    career_stages = CareerStage.objects.all()

    for call in Call.objects.all():
        for career_stage in career_stages:
            CallCareerStage.objects.create(call=call,
                                           career_stage=career_stage)


class Migration(migrations.Migration):
    dependencies = [
        ('project_core', '0163_add_account_number'),
    ]

    operations = [
        migrations.CreateModel(
            name='CallCareerStage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('call', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='project_core.call')),
                ('career_stage',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='project_core.careerstage')),
            ],
        ),
        migrations.RunPython(add_all_career_stages_to_calls)
    ]
