# Generated by Django 2.2.7 on 2019-12-04 11:38

from django.db import migrations

SEARCH_COLUMN = """setweight(to_tsvector('simple_unaccented', COALESCE("name", '')), 'A') || setweight(to_tsvector('simple_unaccented', COALESCE("code_departement", '')), 'B')"""

create_index = f"""
-- noinspection SqlResolve"
CREATE INDEX municipales_communepage_search ON municipales_communepage USING GIN (({SEARCH_COLUMN}));
"""

remove_index = """
DROP INDEX municipales_communepage_search;
"""


class Migration(migrations.Migration):
    dependencies = [
        ("municipales", "0005_communepage_municipales2020_admins"),
    ]

    operations = [migrations.RunSQL(sql=create_index, reverse_sql=remove_index)]
