ALTER TABLE AKUZ.T_MKF_DIAGNOSIS ADD "eventrehabilitationcard" uuid NULL;

UPDATE AKUZ.T_MKF_DIAGNOSIS MKF
	SET EventRehabilitationCard = FPR.EventRehabilitationCard
FROM AKUZ.T_FIRST_PHASE_REHABILITATION FPR 
WHERE MKF.PhaseRehabilitation = FPR.PhaseRehabilitationID;

ALTER TABLE AKUZ.T_MKF_DIAGNOSIS ALTER COLUMN "eventrehabilitationcard" SET NOT NULL;

ALTER TABLE AKUZ.T_MKF_DIAGNOSIS ADD CONSTRAINT FK_T_EVENT_REHABILITATION_CARD_T_MKF_DIAGNOSIS_EventRe_2EBC84A9
FOREIGN KEY("eventrehabilitationcard") REFERENCES AKUZ.T_EVENT_REHABILITATION_CARD (EventRehabilitationCardID);

