-- Tables

-- Alters

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY DROP CONSTRAINT FK_T_LPU_MAIN_T_PREGNANT_ANTI_RHESUS_IG_HISTORY_LPU_MAIN;

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY DROP COLUMN "lpu_main";

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY ADD "users" uuid NULL;

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY ADD "drug" varchar(255) NULL;

UPDATE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY SET "drug" = '';

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY ALTER COLUMN "drug" SET NOT NULL;

ALTER TABLE AKUZ.T_PREGNANT_ANTI_RHESUS_IG_HISTORY ADD CONSTRAINT FK_T_USERS_T_PREGNANT_ANTI_RHESUS_IG_HISTORY_Users
FOREIGN KEY("users") REFERENCES AKUZ.T_USERS (UserID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION DROP COLUMN "newborninformation";

UPDATE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION SET "pregnancytype" = 0 WHERE "pregnancytype" IS NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ALTER COLUMN "pregnancytype" SET NOT NULL;

UPDATE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION SET "outcome" = 0 WHERE "outcome" IS NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ALTER COLUMN "outcome" SET NOT NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ADD "prematurebirth" boolean NULL;

UPDATE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION SET "prematurebirth" = '0';

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ALTER COLUMN "prematurebirth" SET NOT NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ADD "operations" uuid NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ADD "vrttype" integer NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ADD "year" integer NULL;

UPDATE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION SET "year" = 0;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ALTER COLUMN "year" SET NOT NULL;

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION ADD CONSTRAINT FK_T_MEDICAL_SERVICE_T_PREVIOUS_PREGNANCIES_INFORMATIO_59951432
FOREIGN KEY("operations") REFERENCES AKUZ.T_MEDICAL_SERVICE (MedicalServiceID);

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "crueltreatment" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "crueltreatment" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "crueltreatment" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "migrants" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "migrants" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "migrants" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "parentalrightsdeprivation" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "parentalrightsdeprivation" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "parentalrightsdeprivation" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "suicidalattempts" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "suicidalattempts" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "suicidalattempts" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "marginallifestyle" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "marginallifestyle" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "marginallifestyle" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "poor" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "poor" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "poor" SET NOT NULL;

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ADD "disabled" boolean NULL;

UPDATE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS SET "disabled" = '0';

ALTER TABLE AKUZ.T_SOCIOBIOLOGICAL_RISK_FACTORS ALTER COLUMN "disabled" SET NOT NULL;

ALTER TABLE AKUZ.T_OBSTETRICS_RISKS_ANKETA ADD "sociobiologicalrisk" boolean NULL;

UPDATE AKUZ.T_OBSTETRICS_RISKS_ANKETA SET "sociobiologicalrisk" = '0';

ALTER TABLE AKUZ.T_OBSTETRICS_RISKS_ANKETA ALTER COLUMN "sociobiologicalrisk" SET NOT NULL;

