Commit a4f3e1f2 by Nicolas Joyard

Amdts: ajout liste auteurs au vecteur TS

parent 5be488a7
"""Maj trigger TS amendements
Revision ID: 14e3a8ca0ec4
Revises: 0c154fdc1261
Create Date: 2017-04-15 07:56:45.263214
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '14e3a8ca0ec4'
down_revision = '0c154fdc1261'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
conn.execute("""
CREATE OR REPLACE FUNCTION public.amendements_search_vector_update ()
RETURNS trigger
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100
AS $$
BEGIN
NEW.search_vector = (((
to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.numero_long, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_expose, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_dispositif, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi_division, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.auteur_texte_affichable, ''), '[-@.]', ' ', 'g'));
RETURN NEW;
END
$$;
ALTER FUNCTION public.amendements_search_vector_update() OWNER TO parlapi;
""")
def downgrade():
conn = op.get_bind()
conn.execute("""
CREATE OR REPLACE FUNCTION public.amendements_search_vector_update ()
RETURNS trigger
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100
AS $$
BEGIN
NEW.search_vector = (((
to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.numero_long, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_expose, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_dispositif, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi_division, ''), '[-@.]', ' ', 'g'));
RETURN NEW;
END
$$;
ALTER FUNCTION public.amendements_search_vector_update() OWNER TO parlapi;
""")
......@@ -430,7 +430,8 @@ class Amendement(db.Model):
search_vector = db.Column(TSVectorType('numero_long', 'corps_expose',
'corps_dispositif', 'code_loi',
'code_loi_division'))
'code_loi_division',
'auteur_texte_affichable'))
class ActeurAmendement(db.Model):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment