-- ABS-43585/ ABS-44901

CREATE INDEX XIF4INTERNALBUACTIVITIES ON INTERNALBUACTIVITIES (BUSINESSUNIT_ID ASC, ACTIVITY_ID ASC);

ALTER TABLE INTERNALBUACTIVITIES
  ADD CONSTRAINT INTERNALBUACTIVITIES_BUA FOREIGN KEY (BUSINESSUNIT_ID, ACTIVITY_ID)
  REFERENCES BUSINESSUNITACTIVITIES (BUSINESSUNIT_ID, ACTIVITY_ID) ON DELETE CASCADE;

ALTER TABLE INTERNALBUACTIVITIES
  DROP CONSTRAINT INTERNALBUACTIVITIES_ACTIVID;
  
ALTER TABLE INTERNALBUACTIVITIES
  DROP CONSTRAINT INTERNALBUACTIVITIES_BUID;

DROP INDEX XIF1INTERNALBUACTIVITIES;
DROP INDEX XIF2INTERNALBUACTIVITIES;
DROP INDEX XIF3INTERNALBUACTIVITIES;

CREATE INDEX XIE1INTERNALBUACTIVITIES ON INTERNALBUACTIVITIES (BUSINESSUNIT_ID ASC);
CREATE INDEX XIE2INTERNALBUACTIVITIES ON INTERNALBUACTIVITIES (ACTIVITY_ID ASC);

CREATE INDEX XIF1INTERNALBUACTIVITIES ON INTERNALBUACTIVITIES (INTERNALPROCESSINGBU_ID ASC);
