-- Tables

-- Alters

DO $$
BEGIN

     IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = lower('FK_T_ENUMS_T_EHR_TYPE_MEDICAL_DEVICES_HISTORY_ChangeType')) THEN

          ALTER TABLE IES.T_EHR_TYPE_MEDICAL_DEVICES_HISTORY ADD CONSTRAINT FK_T_ENUMS_T_EHR_TYPE_MEDICAL_DEVICES_HISTORY_ChangeType
          FOREIGN KEY("changetype") REFERENCES VCLib.T_ENUMS (EnumID);

     END IF;

END $$;
