 ALTER TABLE partenaires_naturalistes.jacques_nel ADD CONSTRAINT pk_jacques_nel PRIMARY KEY(gid);
 ALTER TABLE partenaires_naturalistes.pierre_frapa ADD CONSTRAINT pk_pierre_frapa PRIMARY KEY(gid);
 ALTER TABLE partenaires_naturalistes.stephane_bence ADD CONSTRAINT pk_stephane_bence PRIMARY KEY(gid);
-
-ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT fk_frin_bib_organismes FOREIGN KEY (id_organisme)
-    REFERENCES utilisateurs.bib_organismes (id_organisme) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
-ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT frin_id_lot_fkey FOREIGN KEY (id_lot)
-    REFERENCES gn_meta.t_datasets (id_dataset) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
-ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT frin_id_protocole_fkey FOREIGN KEY (id_protocole)
+ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT fk_bernard_frin_bib_organismes FOREIGN KEY (id_organisme)
+    REFERENCES utilisateurs.bib_organismes (id_organisme) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
+ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT bernard_frin_id_lot_fkey FOREIGN KEY (id_lot)
+    REFERENCES gn_meta.t_datasets (id_dataset) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
+ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT bernard_frin_id_protocole_fkey FOREIGN KEY (id_protocole)
     REFERENCES gn_meta.sinp_datatype_protocols (id_protocol) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
-ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT frin_id_source_fkey FOREIGN KEY (id_source)
+ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT bernard_frin_id_source_fkey FOREIGN KEY (id_source)
       REFERENCES gn_synthese.t_sources (id_source) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
+ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT bernard_frin_id_critere_synthese_gn1_fkey FOREIGN KEY (id_critere_synthese)
+      REFERENCES hist_archives.bib_criteres_synthese_gn1 (id_critere_synthese) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
 ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT enforce_dims_the_geom_2154 CHECK (public.st_ndims(the_geom_2154) = 2);
 ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT enforce_dims_the_geom_3857 CHECK (public.st_ndims(the_geom_3857) = 2);
 ALTER TABLE partenaires_naturalistes.bernard_frin ADD CONSTRAINT enforce_dims_the_geom_point CHECK (public.st_ndims(the_geom_point) = 2);

-------
--LPO--
-------
IMPORT FOREIGN SCHEMA partenaires LIMIT TO(lpo_paca) FROM SERVER geonature1server INTO v1_compat;
CREATE SCHEMA partenaires_lpo;
CREATE TABLE partenaires_lpo.lpo_paca AS
SELECT * FROM v1_compat.lpo_paca;
ALTER TABLE partenaires_lpo.lpo_paca ADD CONSTRAINT pk_lpo_paca PRIMARY KEY(id_sighting);
ALTER TABLE partenaires_lpo.lpo_paca ADD CONSTRAINT enforce_dims_the_geom_4326 CHECK (st_ndims(the_geom_4326) = 2);
ALTER TABLE partenaires_lpo.lpo_paca ADD CONSTRAINT enforce_geotype_the_geom_4326 CHECK (st_geometrytype(the_geom_4326) = 'ST_Point'::text OR the_geom_4326 IS NULL);

ALTER TABLE v1_imports.importedobs ADD CONSTRAINT importedobs_id_protocole_fkey FOREIGN KEY (id_protocole)
    REFERENCES hist_archives.bib_protocoles (codeprotocole) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
ALTER TABLE v1_imports.importedobs ADD CONSTRAINT importedobs_id_source_fkey FOREIGN KEY (id_source)
    REFERENCES gn_synthese.t_sources (id_source) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
ALTER TABLE v1_imports.importedobs ADD CONSTRAINT importedobs_id_critere_synthese_gn1_fkey FOREIGN KEY (id_critere_synthese)
    REFERENCES hist_archives.bib_criteres_synthese_gn1 (id_critere_synthese) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;
ALTER TABLE v1_imports.importedobs ADD CONSTRAINT enforce_dims_the_geom_2154 CHECK (public.st_ndims(the_geom_2154) = 2);
ALTER TABLE v1_imports.importedobs ADD CONSTRAINT enforce_dims_the_geom_3857 CHECK (public.st_ndims(the_geom_3857) = 2);
ALTER TABLE v1_imports.importedobs ADD CONSTRAINT enforce_dims_the_geom_point CHECK (public.st_ndims(the_geom_point) = 2);
