diff --git a/combo/apps/search/migrations/0007_french_fts.py b/combo/apps/search/migrations/0007_french_fts.py new file mode 100644 index 00000000..b088a26d --- /dev/null +++ b/combo/apps/search/migrations/0007_french_fts.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2020-02-19 08:20 +from __future__ import unicode_literals + +from django.db import migrations +from django.db.migrations.operations.base import Operation + + +class TextSearchConfiguration(Operation): + reversible = True + + def state_forwards(self, app_label, state): + pass + + def database_forwards(self, app_label, schema_editor, from_state, to_state): + if schema_editor.connection.vendor != 'postgresql': + return + schema_editor.execute('CREATE EXTENSION IF NOT EXISTS unaccent SCHEMA public') + schema_editor.execute('CREATE TEXT SEARCH CONFIGURATION french_unaccent( COPY = french )') + schema_editor.execute( + 'ALTER TEXT SEARCH CONFIGURATION french_unaccent ' + 'ALTER MAPPING FOR hword, hword_part, word ' + 'WITH public.unaccent, french_stem') + + def database_backwards(self, app_label, schema_editor, from_state, to_state): + if schema_editor.connection.vendor != 'postgresql': + return + schema_editor.execute('DROP TEXT SEARCH CONFIGURATION french_unaccent') + + def describe(self): + return 'Creates unaccent french text search configuration' + + +class Migration(migrations.Migration): + + dependencies = [ + ('search', '0006_indexedcell'), + ] + + operations = [ + TextSearchConfiguration(), + ] diff --git a/combo/settings.py b/combo/settings.py index 97ce0e48..8b472a9b 100644 --- a/combo/settings.py +++ b/combo/settings.py @@ -256,7 +256,7 @@ MELLON_IDENTITY_PROVIDERS = [] # search services COMBO_SEARCH_SERVICES = {} -POSTGRESQL_FTS_SEARCH_CONFIG = 'french' +POSTGRESQL_FTS_SEARCH_CONFIG = 'french_unaccent' # mapping of payment modes LINGO_NO_ONLINE_PAYMENT_REASONS = {}