# Generated by Django 2.2 on 2019-08-26 14:16

import os

from django.db import migrations


def generate_superuser(apps, schema):
    """ Create superuser using environ data """
    from django.contrib.auth import get_user_model

    UserModel = get_user_model()
    SUPERUSER_EMAIL = os.environ.get('SUPERUSER_EMAIL')
    SUPERUSER_PASSWORD = os.environ.get('SUPERUSER_PASSWORD')

    UserModel.objects.create_superuser(
        email=SUPERUSER_EMAIL,
        password=SUPERUSER_PASSWORD,
    )


class Migration(migrations.Migration):

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

    operations = [
        migrations.RunPython(generate_superuser)
    ]
