-- ABS-39442/ ABS-46389

---PRICELISTUSERGROUP table---
CREATE TABLE PRICELISTUSERGROUP
(
  GENERALPRICELIST_ID NUMBER NOT NULL,
  USERGROUP_ID        NUMBER NOT NULL,
  SYSTEMUSER_ID       NUMBER NOT NULL,
  TIMESTAMP           DATE NOT NULL
)
;

ALTER TABLE PRICELISTUSERGROUP
  ADD CONSTRAINT XPKPRICELISTUSERGROUP PRIMARY KEY (GENERALPRICELIST_ID, USERGROUP_ID);

CREATE INDEX XIF1PRICELISTUSERGROUP ON PRICELISTUSERGROUP (GENERALPRICELIST_ID ASC);
CREATE INDEX XIF2PRICELISTUSERGROUP ON PRICELISTUSERGROUP (USERGROUP_ID ASC);

ALTER TABLE PRICELISTUSERGROUP
  ADD CONSTRAINT PRICELISTUSERGROUP_GPL FOREIGN KEY (GENERALPRICELIST_ID)
  REFERENCES GENERALPRICELIST (GENERALPRICELIST_ID) ON DELETE CASCADE;
  
ALTER TABLE PRICELISTUSERGROUP
  ADD CONSTRAINT PRICELISTUSERGROUP_UG FOREIGN KEY (USERGROUP_ID)
  REFERENCES USERGROUP (USERGROUP_ID) ON DELETE CASCADE;