# Generated by Django 3.0.8 on 2020-08-13 17:29

import os
from django.db import migrations
from django.contrib.auth import get_user_model


def forwards_func(apps, schema_editor):
    """Creates a Django Admin SuperUser for the setup.
    """
    User = get_user_model()

    # retrieve env vars
    SU_NAME = os.environ.get('DJAPP_SU_NAME')
    SU_PASS = os.environ.get('DJAPP_SU_PASS')
    SU_EMAIL = os.environ.get('DJAPP_SU_EMAIL')

    # create superuser
    superuser = User.objects.create_superuser(
        username=SU_NAME,
        email=SU_EMAIL,
        password=SU_PASS,
    )
    superuser.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(forwards_func)
    ]
