   DROP COLUMN with_types,
   DROP COLUMN with_individuals,
   DROP COLUMN with_parts;
+
+ALTER TABLE public.taxonomy DROP CONSTRAINT fct_chk_onceinpath_taxonomy;
+ALTER TABLE public.mineralogy DROP CONSTRAINT fct_chk_onceinpath_mineralogy;
+
+ALTER FUNCTION darwin2.gettagsindexedasarray(character varying) SET SCHEMA public;
+ALTER FUNCTION darwin2.array_accum(anyelement) SET SCHEMA public;
+ALTER FUNCTION darwin2.linetotagarray(text) SET SCHEMA public;
+ALTER FUNCTION darwin2.linetotagrows(text) SET SCHEMA public;
+ALTER FUNCTION darwin2.fct_remove_array_elem(anyarray,anyelement) SET SCHEMA public;
+ALTER FUNCTION darwin2.fct_remove_array_elem(anyarray,anyarray) SET SCHEMA public;
+
+\t
+\o drop_old_d2_triggers.sql
+select DISTINCT 'DROP TRIGGER IF EXISTS ' || trigger_name || ' ON ' || event_object_schema || '.' || event_object_table || ';' 
+FROM information_schema.triggers 
+WHERE event_object_table IN ('taxonomy', 'mineralogy');
+\o
+\i drop_old_d2_triggers.sql
+\! rm drop_old_d2_triggers.sql
+\t
 
 ANALYZE public.flat_abcd;
 ANALYZE public.gtu_properties;

    property_unit,
    CASE WHEN date_from_mask = 0 THEN NULL::timestamp ELSE date_from END ,
    CASE WHEN date_to_mask = 0 THEN NULL::timestamp ELSE date_to END,
    property_type,
    property_sub_type
);

ALTER TABLE public.gtu_properties ADD CONSTRAINT pk_gtu_properties PRIMARY KEY (id);

    m.name as mineral_name,
    f.mineral_ref as mineral_ref,
    m.classification as classification
    FROM  public.identifications_abdc i
    INNER JOIN darwin2.darwin_flat  f on i.flat_id = f.id
    INNER JOIN darwin2.mineralogy m on f.mineral_ref = m.id
    WHERE i.is_current = true
