--ABS-101306/ABS-105913

-----------------------DELIVERYVARIATIONS
ALTER TABLE DELIVERYVARIATIONS ADD (PROCESSBUSINESSUNIT_ID NUMBER NULL,
									INTERNALPROCESSINGBU_ID NUMBER NULL);

CREATE INDEX XIF1DELIVERYVARIATIONS ON DELIVERYVARIATIONS (PROCESSBUSINESSUNIT_ID ASC);
CREATE INDEX XIF2DELIVERYVARIATIONS ON DELIVERYVARIATIONS (INTERNALPROCESSINGBU_ID ASC);


ALTER TABLE DELIVERYVARIATIONS ADD CONSTRAINT FK_DELIVERYVAR_BU FOREIGN KEY (PROCESSBUSINESSUNIT_ID)
REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);

ALTER TABLE DELIVERYVARIATIONS ADD CONSTRAINT FK_DELIVERYVAR_BU1 FOREIGN KEY (INTERNALPROCESSINGBU_ID)
REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);

-----------------------SOILCOUNT
ALTER TABLE SOILCOUNT ADD (INTERNALPROCESSINGBU_ID NUMBER NULL);

DROP INDEX XAK1SOILCOUNT;

CREATE UNIQUE INDEX XAK1SOILCOUNT ON SOILCOUNT
(DISTRIBUTIONPOINT_LINK_ID ASC, COUNTDATE ASC, PROCESSBUSINESSUNIT_ID ASC, BAGTAG_ID ASC, REFERENCENUMBER ASC, INTERNALPROCESSINGBU_ID ASC);

CREATE INDEX XIF3SOILCOUNT ON SOILCOUNT (INTERNALPROCESSINGBU_ID ASC);


ALTER TABLE SOILCOUNT ADD CONSTRAINT FK_SOILCOUNT_BU FOREIGN KEY (INTERNALPROCESSINGBU_ID)
REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);




