# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-09-10 21:54
from __future__ import unicode_literals

from django.db import migrations


def add_file_types(apps, schema_editor):
    FileResource = apps.get_model('tantalus', 'FileResource')
    FileType = apps.get_model('tantalus', 'FileType')

    file_type_choices = (
        'BAM',
        'BAI',
        'FQ',
    )

    for name in file_type_choices:
        extension = '.' + name.lower()
        file_type, _ = FileType.objects.get_or_create(
            name=name, extension=extension)
        f = FileResource.objects.filter(file_type=name)
        f.update(file_type2=file_type)


class Migration(migrations.Migration):

    dependencies = [
        ('tantalus', '0064_auto_20180910_2224'),
    ]

    operations = [
        migrations.RunPython(add_file_types),
    ]
