-- Tables

/***** Object:  Table AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK *****/
CREATE TABLE AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK
(
    "rehabilitationtechnologydictionarylinkid" uuid NOT NULL,
    "rehabilitationtechnologydictionary" uuid NULL,
    "rehabilitationtask" uuid NULL
);

-- Alters

ALTER TABLE AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK ADD CONSTRAINT PK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK
PRIMARY KEY (RehabilitationTechnologyDictionaryLinkID);

ALTER TABLE AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK ADD CONSTRAINT FK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_T_REHABILITA_71F50D8A
FOREIGN KEY("rehabilitationtechnologydictionary") REFERENCES AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY (RehabilitationTechnologyDictionaryID);

ALTER TABLE AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK ADD CONSTRAINT FK_T_REHABILITATION_TASK_T_REHABILITATION_TECHNOLOGY_D_0147BECB
FOREIGN KEY("rehabilitationtask") REFERENCES AKUZ.T_REHABILITATION_TASK (MkfDiagnosisRecordID);

INSERT INTO AKUZ.T_REHABILITATION_TECHNOLOGY_DICTIONARY_LINK ("rehabilitationtechnologydictionarylinkid", "rehabilitationtechnologydictionary","rehabilitationtask")
SELECT gen_random_uuid(), "rehabilitationtaskdictionary", "mkfdiagnosisrecordid"
FROM AKUZ.T_REHABILITATION_TASK;

ALTER TABLE AKUZ.T_REHABILITATION_TASK 
  DROP CONSTRAINT IF EXISTS FK_T_REHABILITATION_TECHNOLOGY_DICTIONARY_T_REHABILITA_4DC2E095;  

ALTER TABLE AKUZ.T_REHABILITATION_TASK DROP COLUMN "rehabilitationtechnologydictionary";