
ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE ADD "patient" uuid NULL;

UPDATE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE SET "patient" = '00000000-0000-0000-0000-000000000000';

ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE ALTER COLUMN "patient" SET NOT NULL;

ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE ADD CONSTRAINT FK_T_PATIENT_T_OBSTETRIC_HOSPITAL_STAGE_Patient
FOREIGN KEY("patient") REFERENCES AKUZ.T_PATIENT (PatientID);

ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE DROP CONSTRAINT FK_T_PREGNANT_DISPANSERISATION_T_OBSTETRIC_HOSPITAL_STAGE_PregnantDispanserisation;

ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE DROP COLUMN "pregnantdispanserisation";


ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE ALTER COLUMN "pregnancynumber" SET DATA TYPE integer;

UPDATE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE SET "pregnancynumber" = 0 WHERE "pregnancynumber" IS NULL;

ALTER TABLE AKUZ.T_OBSTETRIC_HOSPITAL_STAGE ALTER COLUMN "pregnancynumber" SET NOT NULL;


ALTER TABLE AKUZ.T_PREGNANT_DISPANSERISATION ADD "obstetrichospitalstage" uuid NULL;

ALTER TABLE AKUZ.T_PREGNANT_DISPANSERISATION ADD CONSTRAINT FK_T_OBSTETRIC_HOSPITAL_STAGE_T_PREGNANT_DISPANSERISAT_22B7A9B3
FOREIGN KEY("obstetrichospitalstage") REFERENCES AKUZ.T_OBSTETRIC_HOSPITAL_STAGE (ObstetricHospitalStageID);

ALTER TABLE AKUZ.T_PREGNANT_DISPANSERISATION ALTER COLUMN "pregnancynumber" SET DATA TYPE integer;

UPDATE AKUZ.T_PREGNANT_DISPANSERISATION SET "pregnancynumber" = 0 WHERE "pregnancynumber" IS NULL;

ALTER TABLE AKUZ.T_PREGNANT_DISPANSERISATION ALTER COLUMN "pregnancynumber" SET NOT NULL;