
CREATE SCHEMA NICEPORTAL;
CREATE COLUMN TABLE "NICEPORTAL"."UO_CRM_DATA_CONTRACTS" ("ID" BIGINT CS_FIXED NOT NULL ,
	 "ID_MSD" VARCHAR(50) NOT NULL ,
	 "ID_CRM" VARCHAR(30) NOT NULL ,
	 "JSONRAW" NCLOB MEMORY THRESHOLD 1000,
	 "B1_CODE" VARCHAR(50),
	 "CREATE_TS" LONGDATE CS_LONGDATE DEFAULT CURRENT_TIMESTAMP NOT NULL ,
	 "UPDATE_TS" LONGDATE CS_LONGDATE NOT NULL ,
	 PRIMARY KEY ("ID")) UNLOAD PRIORITY 5 AUTO MERGE; 
	 
	 
	 
CREATE SEQUENCE "NICEPORTAL"."SEQ_CONTRACT_ID";
CREATE SEQUENCE "NICEPORTAL"."SEQ_CRMBP_ID";
CREATE SEQUENCE "NICEPORTAL"."SEQ_MAND_ID";
CREATE SEQUENCE "NICEPORTAL"."SEQ_TRANSACTIONDATA_ID";

--DROP TABLE "NICEPORTAL"."UO_CRM_DATA_BP";

CREATE COLUMN TABLE "NICEPORTAL"."UO_CRM_DATA_BP" ("ID" BIGINT CS_FIXED NOT NULL , "ID_MSD" VARCHAR(50) NOT NULL , "ID_CRM" VARCHAR(30) NOT NULL , "TYPE" VARCHAR(1) NOT NULL , "BPGROUP" VARCHAR(10) NOT NULL , "SALUTATION" VARCHAR(20), "TITLE" VARCHAR(20), "NAME" VARCHAR(50) NOT NULL , "SURNAME" VARCHAR(50), "PHONE" VARCHAR(30), "MOBILE_PHONE" VARCHAR(30), "EMAIL" VARCHAR(100), "ADDRESS_JSON" NCLOB MEMORY THRESHOLD 1000, "IBAN" VARCHAR(40), "BIC" VARCHAR(10), "SEPA_MANDATE_ID" VARCHAR(30), "SIGNATURE_DATE" VARCHAR(30), "ACCOUNT_OWNER" VARCHAR(50), "STREET" VARCHAR(50), "STREET_NO" VARCHAR(10), "ZIP_CODE" VARCHAR(10), "CITY" VARCHAR(30), "JSONRAW" NCLOB MEMORY THRESHOLD 1000, "B1_CARDCODE" VARCHAR(50),"RESPONSE_STATUS" VARCHAR(50),"RESPONSE_MESSAGE" NCLOB MEMORY THRESHOLD 1000,"ERROR_MESSAGE" VARCHAR(500), "CREATE_TS" LONGDATE CS_LONGDATE DEFAULT CURRENT_TIMESTAMP NOT NULL , "UPDATE_TS" LONGDATE CS_LONGDATE NOT NULL , PRIMARY KEY ("ID")) UNLOAD PRIORITY 5  AUTO MERGE
;
--DROP TABLE "NICEPORTAL"."CHARGEDATA";
CREATE COLUMN TABLE "NICEPORTAL"."CHARGEDATA" ("ID" BIGINT CS_FIXED NOT NULL ,
	 "CALLID" NVARCHAR(50) NOT NULL UNIQUE,
	 "CDRID" NVARCHAR(50) NOT NULL ,
	 "EVSEID" NVARCHAR(50),
	 "CONTRACTID" NVARCHAR(50),
	 "INSTANCE" NVARCHAR(200),
	 "TOKENTYPE" NVARCHAR(50),
	 "CONSUMEDENERGY" DECIMAL(17,3) CS_FIXED,
	 "OPERATORID" NVARCHAR(50),
	 "OPERATORNAME" NVARCHAR(50),
	 "OPERATORSUBMANDANT" NVARCHAR(50),
	 "FREECHARGE" NVARCHAR(50),
	 "CHARGEPOINTTYPE" NVARCHAR(50),
	 "MAXSOCKETPOWER" DECIMAL(17,3) CS_FIXED,
	 "ADDRESS" NVARCHAR(50),
	 "ZIP" NVARCHAR(50),
	 "CITY" NVARCHAR(50),
	 "COUNTRY" NVARCHAR(50),
	 "PROVIDERID" NVARCHAR(200),
	 "PROVIDERNAME" NVARCHAR(50),
	 "CHARGINGSTARTTIME" NVARCHAR(50),
	 "CHARGINGSTOPTIME" NVARCHAR(50),
	 "PARKINGSTARTTIME" NVARCHAR(50),
	 "PARKINGSTOPTIME" NVARCHAR(50),
	 "METERSTART" DECIMAL(17,3) CS_FIXED,
	 "METERSTOP" DECIMAL(17,3) CS_FIXED,
	 "TARIFF" NVARCHAR(50),
	 "CURRENCY" NVARCHAR(3),
	 "VAT" DECIMAL(17,3) CS_FIXED,
	 "BILLINGVALUEBRUTTO" DECIMAL(17,
	3) CS_FIXED,
	 "BILLINGVALUENETTO" DECIMAL(17,
	3) CS_FIXED,
	 "PARKINGTIMEPRICEBRUTTO" DECIMAL(17,
	3) CS_FIXED,
	 "PARKINGTIMEPRICENETTO" DECIMAL(17,
	3) CS_FIXED,
	 "ADITIONALPRICEBRUTTO" DECIMAL(17,
	3) CS_FIXED,
	 "ADITIONALPRICENETTO" DECIMAL(17,
	3) CS_FIXED,
	 "B2CPRICING" NCLOB MEMORY THRESHOLD 1000,
	 	 "ASSETOWNERPRICING" NCLOB MEMORY THRESHOLD 1000,
	 	 	 "CPOPRICING" NCLOB MEMORY THRESHOLD 1000,
	 "JSONRAW" NCLOB MEMORY THRESHOLD 1000,
	 "CREATE_TS" LONGDATE CS_LONGDATE DEFAULT CURRENT_TIMESTAMP NOT NULL ,
	 "UPDATE_TS" LONGDATE CS_LONGDATE NOT NULL ,
	 PRIMARY KEY ("ID")) UNLOAD PRIORITY 5 AUTO MERGE 