# Generated by Django 3.2.5 on 2021-08-10 08:12

import os

import django_extensions.db.fields
from django.db import migrations, models


def parse_skills_file(apps, schema_editor):
    """Parse file skills.txt and save data to Skill model."""
    module_dir = os.path.dirname(__file__)
    file_path = os.path.join(module_dir, "../data/skills.txt")
    with open(file_path) as f:
        data = f.read().split("\n")
    Skill = apps.get_model('skills', 'Skill')
    for item in data:
        Skill.objects.create(name=item)


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Skill',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(max_length=64, unique=True, verbose_name='Name')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.RunPython(parse_skills_file)
    ]
