# Generated by Django 2.2.5 on 2019-09-21 11:13

from django.db import migrations


def set_default_dataset(apps, schema_editor):
    Action = apps.get_model('kodomo', 'Action')
    Log = apps.get_model('kodomo', 'Log')
    Bank = apps.get_model('kodomo', 'Bank')
    Ticket = apps.get_model('kodomo', 'Ticket')
    Style = apps.get_model('kodomo', 'Style')
    Value = apps.get_model('kodomo', 'Value')
    User = apps.get_model('kodomo', 'User')

    Action.objects.create(content="チケットを使ったとき")
    Action.objects.create(content="チケットを買ったとき")
    Action.objects.create(content="降ろしたとき")

    Style.objects.create(color="#399D26", icon="air-freshener")
    Style.objects.create(color="#00267F", icon="baseball-ball")
    Style.objects.create(color="#B40019", icon="anchor")
    Style.objects.create(color="#431274", icon="apple-alt")
    Style.objects.create(color="#0099DB", icon="book-open")
    Style.objects.create(color="#0099DB", icon="air-freshener")
    Style.objects.create(color="#431274", icon="baseball-ball")
    Style.objects.create(color="#B40019", icon="anchor")
    Style.objects.create(color="#00267F", icon="apple-alt")
    Style.objects.create(color="#399D26", icon="book-open")

    Value.objects.create(price=5, cost=0)
    Value.objects.create(price=10, cost=2)
    Value.objects.create(price=50, cost=10)
    Value.objects.create(price=100, cost=20)


def delete_default_dataset(apps, schema_editor):
    Action = apps.get_model('kodomo', 'Action')
    Log = apps.get_model('kodomo', 'Log')
    Bank = apps.get_model('kodomo', 'Bank')
    Ticket = apps.get_model('kodomo', 'Ticket')
    Color = apps.get_model('kodomo', 'Color')
    Price = apps.get_model('kodomo', 'Price')
    User = apps.get_model('kodomo', 'User')

    Action.objects.all().delete()
    Log.objects.all().delete()
    Bank.objects.all().delete()
    Ticket.objects.all().delete()
    Color.objects.all().delete()
    Price.objects.all().delete()
    User.objects.all().delete()


class Migration(migrations.Migration):

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

    operations = [
        migrations.RunPython(set_default_dataset, delete_default_dataset),
    ]

