CONSTRAINT must be set in inherited tables (e.g. there is no real data in fish table), same for trigger but function remains unchanged
ALTER TABLE datawg.t_fishseries_fiser ADD CONSTRAINT c_fk_fiser_dts_datasource FOREIGN KEY (fi_dts_datasource) REFERENCES "ref".tr_datasource_dts(dts_datasource) ON UPDATE CASCADE;
ALTER TABLE datawg.t_fishsamp_fisa ADD CONSTRAINT c_fk_fisa_dts_datasource
FOREIGN KEY (fi_dts_datasource) REFERENCES "ref".tr_datasource_dts(dts_datasource) ON UPDATE CASCADE;
CREATE TRIGGER update_fi_lastupdate BEFORE INSERT OR UPDATE ON
datawg.t_fishseries_fiser FOR EACH ROW EXECUTE FUNCTION datawg.fi_lastupdate();
create trigger update_gr_lastupdate BEFORE insert OR update on
datawg.t_groupseries_grser for each row execute function datawg.gr_lastupdate();
CREATE TRIGGER update_fi_lastupdate BEFORE INSERT OR UPDATE ON
datawg.t_fishsamp_fisa FOR EACH ROW EXECUTE FUNCTION datawg.fi_lastupdate();
create trigger update_gr_lastupdate BEFORE insert OR update on
datawg.t_groupseries_grser for each row execute function datawg.gr_lastupdate();
create trigger update_gr_lastupdate BEFORE insert OR update on
datawg.t_groupsamp_grsa for each row execute function datawg.gr_lastupdate();
DROP TRIGGER IF EXISTS update_meg_last_update ON datawg.datawg.t_metricgroupseries_megser ;
CREATE TRIGGER update_meg_last_update BEFORE INSERT OR UPDATE ON
datawg.datawg.t_metricgroupseries_megser FOR EACH ROW EXECUTE FUNCTION datawg.meg_last_update();
DROP TRIGGER IF EXISTS update_meg_last_update ON datawg.t_metricgroupsamp_megsa ;
CREATE TRIGGER update_meg_last_update BEFORE INSERT OR UPDATE ON
datawg.t_metricgroupsamp_megsa FOR EACH ROW EXECUTE FUNCTION datawg.meg_last_update();
DROP TRIGGER IF EXISTS check_meg_mty_is_group ON datawg.t_metricgroupseries_megser;
CREATE TRIGGER check_meg_mty_is_group AFTER INSERT OR UPDATE ON
datawg.t_metricgroupseries_megser FOR EACH ROW EXECUTE FUNCTION datawg.meg_mty_is_group();
DROP TRIGGER IF EXISTS check_meg_mty_is_group ON datawg.t_metricgroupsamp_megsa;
CREATE TRIGGER check_meg_mty_is_group AFTER INSERT OR UPDATE ON
datawg.t_metricgroupsamp_megsa FOR EACH ROW EXECUTE FUNCTION datawg.meg_mty_is_group();
CONSTRAINT must be set in inherited tables (e.g. there is no real data in fish table), same for trigger but function remains unchanged