[saem-devel] [PATCH 1 of 2 V2] [migration] Recreate pg_trgm specific indexes if necessary

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Jan 31 10:44:34 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1485797437 -3600
#      Mon Jan 30 18:30:37 2017 +0100
# Node ID 8abe94bd44cd242035b9fdd4f5ad64a7ca225fa1
# Parent  34adf62121166742ee621c6048d4a5eeaaed861b
[migration] Recreate pg_trgm specific indexes if necessary

They may be erroneously dropped by cw 3.24 migration. Put this in a try/except
in case indexes already exist.

diff --git a/cubicweb_saem_ref/migration/0.14.0_Any.py b/cubicweb_saem_ref/migration/0.14.0_Any.py
--- a/cubicweb_saem_ref/migration/0.14.0_Any.py
+++ b/cubicweb_saem_ref/migration/0.14.0_Any.py
@@ -20,5 +20,13 @@ drop_cube('pyramid')
 schema_wf = get_workflow_for('ConceptScheme')
 with cnx.deny_all_hooks_but():
     rql('SET X in_state S WHERE X is ConceptScheme, S eid %(s)s, NOT X in_state Y',
         {'s': schema_wf.state_by_name('published').eid})
 commit()
+
+
+try:
+    sql('CREATE UNIQUE INDEX words_unique_idx ON words (etype, word)')
+    sql('CREATE INDEX words_word_idx ON words USING gin(word gin_trgm_ops)')
+    commit(ask_confirm=False)
+except Exception:
+    rollback()


More information about the saem-devel mailing list