-- ABS-70817 / ABS-81437
--- CONTRACTEMBTEMPLINECUST ---
CREATE TABLE CONTRACTEMBTEMPLINECUST
(
CONTRACTEMBTEMPLINE_ID NUMBER NOT NULL,
EMBLEMTEMPLATELINE_ID NUMBER NOT NULL,
SYSTEMUSER_ID NUMBER NOT NULL,
TIMESTAMP DATE NOT NULL
);

ALTER TABLE CONTRACTEMBTEMPLINECUST ADD CONSTRAINT XPKCONTRACTEMBTEMPLINECUST PRIMARY KEY (CONTRACTEMBTEMPLINE_ID, EMBLEMTEMPLATELINE_ID);

CREATE UNIQUE INDEX XAK1CONTRACTEMBTEMPLINECUST ON CONTRACTEMBTEMPLINECUST (EMBLEMTEMPLATELINE_ID ASC);
CREATE INDEX XIF1CONTRACTEMBTEMPLINECUST ON CONTRACTEMBTEMPLINECUST (CONTRACTEMBTEMPLINE_ID ASC);

ALTER TABLE CONTRACTEMBTEMPLINECUST ADD CONSTRAINT CONTRACTEMBTEMPLINECUST_CETL FOREIGN KEY (CONTRACTEMBTEMPLINE_ID)
REFERENCES CONTRACTEMBTEMPLINE (CONTRACTEMBTEMPLINE_ID) ON DELETE CASCADE;

ALTER TABLE CONTRACTEMBTEMPLINECUST ADD CONSTRAINT CONTRACTEMBTEMPLINECUST_ETL FOREIGN KEY (EMBLEMTEMPLATELINE_ID)
REFERENCES EMBLEMTEMPLATELINE (EMBLEMTEMPLATELINE_ID) ON DELETE CASCADE;