-- ABS-153490 CREATE NEW DB TABLE CONTAINERCONTENTHEADER / CONTAINERCONTENTLINEABS-154850

CREATE SEQUENCE SEQ_CONTAINERCONTENTBUNDLE 
START WITH 1
INCREMENT BY 1;

CREATE TABLE CONTAINERCONTENTBUNDLE (
  CONTAINERCONTENTBUNDLE_ID NUMBER NOT NULL,
  CONTAINER_ID NUMBER NOT NULL,
  UNIQUEBUNDLE_ID NUMBER NOT NULL,
  CREATIONTIMESTAMP DATE NOT NULL,
  CREATIONUSER_ID NUMBER NOT NULL,
  TIMESTAMP DATE NOT NULL,
  SYSTEMUSER_ID NUMBER NOT NULL
);
  
ALTER TABLE CONTAINERCONTENTBUNDLE 
ADD CONSTRAINT XPKCONTAINERCONTENTBUNDLE PRIMARY KEY (CONTAINERCONTENTBUNDLE_ID);

CREATE UNIQUE INDEX XAK1CONTAINERCONTENTBUNDLE ON CONTAINERCONTENTBUNDLE (CONTAINER_ID ASC, UNIQUEBUNDLE_ID ASC);
CREATE INDEX XIF1CONTAINERCONTENTBUNDLE ON CONTAINERCONTENTBUNDLE (CONTAINER_ID ASC);
CREATE INDEX XIF2CONTAINERCONTENTBUNDLE ON CONTAINERCONTENTBUNDLE (UNIQUEBUNDLE_ID ASC);

ALTER TABLE CONTAINERCONTENTBUNDLE
ADD CONSTRAINT FK_CONTAINERCONTENTBUNDLE_CONTAINERID FOREIGN KEY (CONTAINER_ID) REFERENCES CONTAINER (CONTAINER_ID) ON DELETE CASCADE;

ALTER TABLE CONTAINERCONTENTBUNDLE
ADD CONSTRAINT FK_CONTAINERCONTENTBUNDLE_UNIQUEBUNDLEID FOREIGN KEY (UNIQUEBUNDLE_ID) REFERENCES UNIQUEBUNDLE (UNIQUEBUNDLE_ID) ON DELETE CASCADE;