# Generated by Django 3.0.14 on 2021-08-18 20:30

from django.db import migrations


def _create_idx(fld):
    #  create  index foo114 on pbn_api_publication using gin (upper("title") gin_trgm_ops);
    idx_name = f"pbn_api_pub_{fld}_idx"
    create = f'CREATE INDEX {idx_name} ON pbn_api_publication USING GIN (UPPER("{fld}") gin_trgm_ops);'
    delete = f"DROP INDEX {idx_name}"
    return create, delete


class Migration(migrations.Migration):

    dependencies = [
        ("pbn_api", "0027_przemapuj_rok_publikacji"),
    ]

    operations = [
        migrations.RunSQL(*_create_idx("mongoId")),
        migrations.RunSQL(*_create_idx("title")),
        migrations.RunSQL(*_create_idx("publicUri")),
        migrations.RunSQL(*_create_idx("doi")),
        migrations.RunSQL(*_create_idx("isbn")),
    ]
