-- Tables

-- Alters

ALTER TABLE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT ADD "palliativeregistry" uuid NULL;

UPDATE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT 
	SET "palliativeregistry" = AKUZ.T_PALLIATIVE_CARE_RECORD.PallieativeRegistry
from AKUZ.T_PALLIATIVE_CARE_RECORD on AKUZ.T_PALLIATIVE_CARE_RECORD.PalliativeCareRecordID = AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT.PalliativeCareRecord;

ALTER TABLE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT ALTER COLUMN "palliativeregistry" SET NOT NULL;

ALTER TABLE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT ADD CONSTRAINT FK_T_PALLIATIVE_REGISTRY_T_PALLIATIVE_USED_MEDICAL_EQU_93F77065
FOREIGN KEY("palliativeregistry") REFERENCES AKUZ.T_PALLIATIVE_REGISTRY (PalliativeRegistryID);

ALTER TABLE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT DROP CONSTRAINT FK_T_PALLIATIVE_CARE_RECORD_T_PALLIATIVE_USED_MEDICAL__A035C9C7;

ALTER TABLE AKUZ.T_PALLIATIVE_USED_MEDICAL_EQUIPMENT DROP COLUMN "palliativecarerecord";