---ABS-14132/ ABS-52958

---SHIPMENTLISTLINEORPACK table---
CREATE SEQUENCE SEQ_SHIPMENTLISTLINEORPACK
START WITH 1
INCREMENT BY 1;

CREATE TABLE SHIPMENTLISTLINEORPACK
(
  SHIPMENTLISTLINEORPACK_ID NUMBER NOT NULL,
  SHIPMENTLISTLINE_ID       NUMBER NOT NULL,
  UNIQUEITEM_ID             NUMBER NOT NULL,
  SYSTEMUSER_ID             NUMBER NOT NULL,
  TIMESTAMP                 DATE NOT NULL
)
;

COMMENT ON COLUMN SHIPMENTLISTLINEORPACK.UNIQUEITEM_ID
  IS 'should only be OR packs';

ALTER TABLE SHIPMENTLISTLINEORPACK
  ADD CONSTRAINT XPKSHIPMENTLISTLINEORPACK PRIMARY KEY (SHIPMENTLISTLINEORPACK_ID);
  
CREATE UNIQUE INDEX XAK1SHIPMENTLISTLINEORPACK ON SHIPMENTLISTLINEORPACK (SHIPMENTLISTLINE_ID ASC, UNIQUEITEM_ID ASC);
  
CREATE INDEX XIF1SHIPMENTLISTLINEORPACK ON SHIPMENTLISTLINEORPACK (SHIPMENTLISTLINE_ID ASC);
CREATE INDEX XIF2SHIPMENTLISTLINEORPACK ON SHIPMENTLISTLINEORPACK (UNIQUEITEM_ID ASC);

ALTER TABLE SHIPMENTLISTLINEORPACK
  ADD CONSTRAINT SHIPMENTLISTLINEORPACK_SLL FOREIGN KEY (SHIPMENTLISTLINE_ID)
  REFERENCES SHIPMENTLISTLINE (SHIPMENTLISTLINE_ID) ON DELETE CASCADE;
  
ALTER TABLE SHIPMENTLISTLINEORPACK
  ADD CONSTRAINT SHIPMENTLISTLINEORPACK_UI FOREIGN KEY (UNIQUEITEM_ID)
  REFERENCES UNIQUEITEM (UNIQUEITEM_ID) ON DELETE CASCADE;
