-- ABS-75637 / ABS-103247
--- CONTRACTSPECIALCHARGE ---
DROP INDEX XAK1CONTRACTSPECIALCHARGE;

ALTER TABLE CONTRACTSPECIALCHARGE DROP CONSTRAINT XPKCONTRACTSPECIALCHARHE CASCADE;

ALTER TABLE CONTRACTSPECIALCHARGE DROP COLUMN CONTRACTSPECIALCHARGE_ID;

DROP SEQUENCE SEQ_CONTRACTSPECIALCHARGE;

ALTER TABLE CONTRACTSPECIALCHARGE ADD CONSTRAINT XPKCONTRACTSPECIALCHARGE PRIMARY KEY (CONTRACT_ID, SPECIALCHARGE_ID);

--- CONTRACTSPECIALCHARGECUST ---
DROP INDEX XIF1CONTRACTSPECIALCHARGECUST;

ALTER TABLE CONTRACTSPECIALCHARGECUST DROP CONSTRAINT FK_CONTRSPECCHARCUST_CONSPCHAR;
ALTER TABLE CONTRACTSPECIALCHARGECUST DROP CONSTRAINT XPKCONTRACTSPECIALCHARGECUST;

ALTER TABLE CONTRACTSPECIALCHARGECUST DROP COLUMN CONTRACTSPECIALCHARGE_ID;

ALTER TABLE CONTRACTSPECIALCHARGECUST ADD (CONTRACT_ID NUMBER NOT NULL);

ALTER TABLE CONTRACTSPECIALCHARGECUST ADD CONSTRAINT XPKCONTRACTSPECIALCHARGECUST PRIMARY KEY (CONTRACT_ID, CUSTOMER_ID, SPECIALCHARGE_ID);

CREATE INDEX XIF1CONTRACTSPECIALCHARGECUST ON CONTRACTSPECIALCHARGECUST (CONTRACT_ID ASC);

ALTER TABLE CONTRACTSPECIALCHARGECUST ADD CONSTRAINT FK_CONTRSPECCHARCUST_CONTSPCH FOREIGN KEY (CONTRACT_ID, SPECIALCHARGE_ID)
REFERENCES CONTRACTSPECIALCHARGE (CONTRACT_ID, SPECIALCHARGE_ID) ON DELETE CASCADE;