# Generated by Django 3.1.3 on 2021-01-01 23:16

import django
from django.db import migrations, models


def add_profile_channels(apps, schema_edito):
    Profile = apps.get_model("epic", "Profile")
    Channel = apps.get_model("epic", "Channel")
    Channel.objects.bulk_create(
        [
            Channel(id=_id, server_id=server_id)
            for (_id, server_id) in Profile.objects.values_list("channel", "server_id")
        ],
        ignore_conflicts=True,
    )


def noop(apps, schema_editor):
    return None


class Migration(migrations.Migration):

    dependencies = [
        ("epic", "0015_adjust_gamble_created"),
    ]

    operations = [
        migrations.CreateModel(
            name="Channel",
            fields=[
                ("id", models.PositiveIntegerField(primary_key=True, serialize=False)),
                ("name_at_creation", models.CharField(blank=True, max_length=150, null=True)),
                ("server", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="epic.server")),
            ],
        ),
        migrations.RunPython(add_profile_channels, noop),
    ]
