# Generated by Django 2.2.12 on 2020-05-29 07:53
import os

import django.contrib.postgres.search
from django.db import connection, migrations, models


def load_triggers(apps, schema_editor):
    file_names = [
        "triggers_feature.sql",
        # "triggers_mapping.sql",
    ]
    with connection.cursor() as c:
        for file_name in file_names:
            file_path = os.path.join(os.path.dirname(__file__), file_name)
            with open(file_path) as fh:
                sql_statement = fh.read()
            c.execute(sql_statement)


class Migration(migrations.Migration):

    dependencies = [
        ("resolwe_bio_kb", "0008_callable_defaults"),
        ("flow", "0043_full_text_search"),
    ]

    operations = [
        migrations.AddField(
            model_name="feature",
            name="search",
            field=django.contrib.postgres.search.SearchVectorField(null=True),
        ),
        migrations.RunPython(load_triggers),
        # Update existing entries.
        migrations.RunSQL("UPDATE resolwe_bio_kb_feature SET id=id;"),
        migrations.AddIndex(
            model_name="feature",
            index=models.Index(fields=["source"], name="idx_feature_source"),
        ),
        migrations.AddIndex(
            model_name="feature",
            index=models.Index(fields=["species"], name="idx_feature_species"),
        ),
        migrations.AddIndex(
            model_name="feature",
            index=models.Index(fields=["feature_id"], name="idx_feature_feature_id"),
        ),
        migrations.AddIndex(
            model_name="feature",
            index=django.contrib.postgres.indexes.GinIndex(
                fields=["search"], name="idx_feature_search"
            ),
        ),
    ]

@@ -678,16 +678,30 @@
 flow%22, %22
+0001_squashed_
 0043_ful

Fix migrations to match Resolwe