Skip to content

Commit

Permalink
refactor(db): replace vm by index in taxref
Browse files Browse the repository at this point in the history
Updated sql function not to use vm but to select in taxref instead
  • Loading branch information
Maxime Vergez committed Oct 16, 2023
1 parent 76b8d86 commit 12b26cd
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@
def upgrade():
op.execute(
"""
CREATE MATERIALIZED VIEW taxonomie.vm_group3_inpn
TABLESPACE pg_default
AS SELECT DISTINCT tx.group3_inpn
FROM taxonomie.taxref tx
WHERE tx.group3_inpn notnull
WITH DATA;
CREATE UNIQUE INDEX i_unique_group3_inpn ON taxonomie.vm_group3_inpn USING btree (group3_inpn);
"""
CREATE INDEX i_taxref_group3_inpn ON taxonomie.taxref USING btree (group3_inpn);
"""
)

op.execute(
Expand All @@ -38,7 +32,7 @@ def upgrade():
AS $function$
--fonction permettant de vérifier si un texte proposé correspond à un group3_inpn dans la table taxref
BEGIN
IF mygroup IN(SELECT group3_inpn FROM taxonomie.vm_group3_inpn) OR mygroup IS NULL THEN
IF EXISTS (SELECT 1 FROM taxonomie.taxref WHERE group3_inpn = mygroup ) OR mygroup IS NULL THEN
RETURN true;
ELSE
RETURN false;
Expand All @@ -51,5 +45,5 @@ def upgrade():


def downgrade():
op.execute("DROP MATERIALIZED VIEW taxonomie.vm_group3_inpn")
op.execute("DROP INDEX taxonomie.i_taxref_group3_inpn")
op.execute("DROP FUNCTION taxonomie.check_is_group3inpn")

0 comments on commit 12b26cd

Please sign in to comment.