from django.db import migrations

CATEGORIES = [
    ('loader', 'Loader', '#3a86ff'),
    ('version', 'Version', '#8338ec'),
    ('general', 'General', '#666666'),
    ('creator', 'Creator', '#fb5607'),
    ('content', 'Content', '#d62828'),
    ('species', 'Species', '#06a77d'),
    ('non_version', 'NoN Version', '#9d4edd'),
]


def seed_categories(apps, schema_editor):
    TagCategory = apps.get_model('library', 'TagCategory')
    for slug, name, color in CATEGORIES:
        TagCategory.objects.update_or_create(slug=slug, defaults={'name': name, 'color': color})


def unseed_categories(apps, schema_editor):
    TagCategory = apps.get_model('library', 'TagCategory')
    TagCategory.objects.filter(slug__in=[c[0] for c in CATEGORIES]).delete()


class Migration(migrations.Migration):

    dependencies = [
        ('library', '0002_tagcategory_project_projectasset_tag_taglist_version_and_more'),
    ]

    operations = [
        migrations.RunPython(seed_categories, unseed_categories),
    ]
