--
-- personality_cluster_info
--
CREATE SEQUENCE pers_clst_info_seq;

CREATE TABLE personality_cluster_info (
	id INTEGER, 
	personality_id INTEGER, 
	cluster_type VARCHAR(16 CHAR), 
	creation_date DATE, 
	CONSTRAINT pers_clst_info_pk PRIMARY KEY (id), 
	CONSTRAINT pers_clst_info_pers_fk FOREIGN KEY(personality_id) REFERENCES personality (id) ON DELETE CASCADE, 
	CONSTRAINT pers_clst_info_pc_uk UNIQUE (personality_id, cluster_type)
);

ALTER TABLE "PERSONALITY_CLUSTER_INFO"
	MODIFY ("ID" CONSTRAINT "PERS_CLSTR_ID_NN" NOT NULL ENABLE);
ALTER TABLE "PERSONALITY_CLUSTER_INFO"
	MODIFY ("PERSONALITY_ID" CONSTRAINT "PERS_CLSTR_PRSNLTY_ID_NN" NOT NULL ENABLE);
ALTER TABLE "PERSONALITY_CLUSTER_INFO"
	MODIFY ("CLUSTER_TYPE" CONSTRAINT "PERS_CLSTR_CLSTR_TYP_NN" NOT NULL ENABLE);
ALTER TABLE "PERSONALITY_CLUSTER_INFO"
	MODIFY ("CREATION_DATE" CONSTRAINT "PERS_CLSTR_CR_DATE_NN" NOT NULL ENABLE);

--
-- personality_esx_cluster_info
--
CREATE TABLE personality_esx_cluster_info (
	personality_cluster_info_id INTEGER, 
	vmhost_capacity_function VARCHAR(255 CHAR), 
	vmhost_overcommit_memory FLOAT, 
	CONSTRAINT pers_esxcl_info_pk PRIMARY KEY (personality_cluster_info_id), 
	CONSTRAINT pers_esxcl_info_pci_fk FOREIGN KEY(personality_cluster_info_id) REFERENCES personality_cluster_info (id) ON DELETE CASCADE
);

ALTER TABLE "PERSONALITY_ESX_CLUSTER_INFO"
	MODIFY ("PERSONALITY_CLUSTER_INFO_ID" CONSTRAINT "PERS_ESXCLSTR_PERS_CLSTRID_NN" NOT NULL ENABLE);
ALTER TABLE "PERSONALITY_ESX_CLUSTER_INFO"
	MODIFY ("VMHOST_OVERCOMMIT_MEMORY" CONSTRAINT "PERS_ESXCLSTR_VM_OVRCMT_MEM_NN" NOT NULL ENABLE);

--
-- metacluster
--
ALTER TABLE "METACLUSTER" ADD ("HIGH_AVAILABILITY" SMALLINT);

UPDATE "METACLUSTER" SET HIGH_AVAILABILITY = 0;

ALTER TABLE "METACLUSTER" MODIFY ("HIGH_AVAILABILITY" CONSTRAINT "METACLUSTER_HA_NN" NOT NULL ENABLE);
ALTER TABLE "METACLUSTER" ADD CONSTRAINT "METACLUSTER_HA_CHECK" CHECK ("HIGH_AVAILABILITY" IN (0, 1)) ENABLE;

--
-- esx_cluster
--
ALTER TABLE "ESX_CLUSTER" ADD ("MEMORY_CAPACITY" INTEGER);

COMMIT;

Add the DB upgrade script
Add the DB upgrade script
