 ----------------------------------
 -- VIEWS AND MATERIALIZED VIEWS --
 ----------------------------------
+
 CREATE MATERIALIZED VIEW gn_profiles.vm_valid_profiles AS
 SELECT DISTINCT
 	t.cd_ref AS cd_ref,

---------------
--PRIMARY KEY--
---------------
ALTER TABLE ONLY gn_profiles.t_parameters 
	ADD CONSTRAINT pk_parameters PRIMARY KEY (id_parameter);


LEFT JOIN taxonomie.taxref t ON p.cd_nom=t.cd_nom;


-- Rafraichissement des vues matérialisées des profils
-- USAGE : SELECT gn_profiles.refresh_profiles()
CREATE OR REPLACE FUNCTION gn_profiles.refresh_profiles()
RETURNS VOID AS $$
BEGIN
  REFRESH MATERIALIZED VIEW CONCURRENTLY gn_profiles.vm_valid_profiles;
  REFRESH MATERIALIZED VIEW CONCURRENTLY gn_profiles.vm_cor_taxon_phenology;
END
$$ LANGUAGE plpgsql;

-----------
-- INDEX --
-----------
