-- ABS-69595
--- CONTRACTEMBTEMPLINE ---
ALTER TABLE CONTRACTEMBTEMPLINE
  DROP CONSTRAINT CONTRACTEMBTEMPLINE_EMBLEMTEMP;
ALTER TABLE CONTRACTEMBTEMPLINE
  ADD CONSTRAINT CONTRACTEMBTEMPLINE_EMBLEMTEMP FOREIGN KEY (CONTRACTEMBTEMP_ID)
  REFERENCES CONTRACTEMBTEMP (CONTRACTEMBTEMP_ID) ON DELETE CASCADE;

--- CONTRACTCOMPONENTGRMSETTINGS ---
ALTER TABLE CONTRACTCOMPONENTGRMSETTINGS DROP COLUMN GARMENTRENTSPECIFICATION CASCADE CONSTRAINTS;

--- CONTRACTCOMPONENTGRMCHARGES ---
ALTER TABLE CONTRACTCOMPONENTGRMCHARGES ADD (GARMENTRENTSPECIFICATION NUMBER NULL
				CONSTRAINT GARMENTRENTSPEC_VALID1 CHECK (GARMENTRENTSPECIFICATION BETWEEN 0 AND 7));

COMMENT ON COLUMN CONTRACTCOMPONENTGRMCHARGES.GARMENTRENTSPECIFICATION IS '0 = Not applicable
1 = Products per Wearer
2 = Products per Wearer Condensed
3 = Wearer totals only
4 = Quantities per Product
5 = Number of men per total price
6 = Wearer function
7 = Wearer Function Fixed Total Price';

--- CONTRACTDEFWEARINVPRICE ---
CREATE SEQUENCE SEQ_CONTRACTDEFWEARINVPRICE
START WITH 1
INCREMENT BY 1;

CREATE TABLE CONTRACTDEFWEARINVPRICE
(
CONTRACTDEFWEARINVPRICE_ID NUMBER NOT NULL,
STANDARDINVENTORY_ID NUMBER NOT NULL,
PRICE NUMBER NOT NULL,
STARTDATE DATE NOT NULL,
SYSTEMUSER_ID NUMBER NOT NULL,
TIMESTAMP DATE NOT NULL
);

ALTER TABLE CONTRACTDEFWEARINVPRICE ADD CONSTRAINT XPKCONTRACTDEFWEARINVPRICE PRIMARY KEY (CONTRACTDEFWEARINVPRICE_ID);

CREATE UNIQUE INDEX XAK1CONTRACTDEFWEARINVPRICE ON CONTRACTDEFWEARINVPRICE (STANDARDINVENTORY_ID ASC, STARTDATE ASC);
CREATE INDEX XIF1CONTRACTDEFWEARINVPRICE ON CONTRACTDEFWEARINVPRICE (STANDARDINVENTORY_ID ASC);

ALTER TABLE CONTRACTDEFWEARINVPRICE ADD CONSTRAINT CONTRACTDEFWEARINVPRICE_SDINV FOREIGN KEY (STANDARDINVENTORY_ID)
REFERENCES STANDARDINVENTORY (STANDARDINVENTORY_ID) ON DELETE CASCADE;




