# Generated by Django 2.1.3 on 2018-11-21 18:15

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ('grafit', '0011_remove_article_related'),
    ]

    operations = [
        migrations.RunSQL(
            """
            DROP MATERIALIZED VIEW IF EXISTS grafit_search_index;

            CREATE MATERIALIZED VIEW grafit_search_index AS
                SELECT 
                    node.id, 
                    node.title, 
                    setweight(to_tsvector('english', node.title), 'A') ||
                    setweight(to_tsvector('english', node.text), 'B') as document
                FROM grafit_article AS node
                GROUP BY node.id;

            DROP INDEX IF EXISTS idx_grafit_search_index;

            CREATE INDEX idx_grafit_search_index
            ON grafit_search_index
            USING gin (document);
            """
        ),
    ]
