Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
CREATE TABLE demand_v3v1_copy
(
    id character varying(64) NOT NULL,
    consumercode character varying(250) NOT NULL,
    consumertype character varying(250) NOT NULL,
    businessservice character varying(250) NOT NULL,
    payer character varying(250),
    taxperiodfrom bigint NOT NULL,
    taxperiodto bigint NOT NULL,
    createdby character varying(256) NOT NULL,
    createdtime bigint NOT NULL,
    lastmodifiedby character varying(256),
    lastmodifiedtime bigint,
    tenantid character varying(250) NOT NULL,
    minimumamountpayable numeric(12,2),
    status character varying(64),
    additionaldetails json,
    billexpirytime bigint
);

INSERT INTO demand_v3v1_copy SELECT * FROM egbs_demand_v1;

ALTER TABLE egbs_demand_v1 ADD codeid VARCHAR(250) NULL;

UPDATE egbs_demand_v1 SET consumercodecodeid = SPLIT_PART(consumercode,':',1);

UPDATE egbs_demand_v1 SET status = 'INACTIVE' FROM (SELECT consumercodecodeid,taxperiodfrom,taxperiodto, MAX(lastmodifiedtime) AS MAXTIME FROM egbs_demand_v1 GROUP BY consumercodecodeid,taxperiodfrom,taxperiodto) AS demand WHERE egbs_demand_v1.consumercodetaxperiodfrom = demand.consumercodetaxperiodfrom AND egbs_demand_v1.taxperiodfromtaxperiodto = demand.taxperiodfromtaxperiodto AND egbs_demand_v1.taxperiodtolastmodifiedtime =< demand.taxperiodtoMAXTIME AND egbs_demand_v1.lastmodifiedtimecodeid <= demand.MAXTIMEcodeid;

UPDATE egbs_demand_v1 SET consumercode = codeid;

ALTER TABLE egbs_demand_v1 DROP COLUMN codeid;

UPDATE egcl_receiptheader SET consumercode = SPLIT_PART(consumercode,':',1);

UPDATE egbs_billdetail_v1 SET consumercode = SPLIT_PART(consumercode,':',1);

...