-- ABS-64247
--- CONTRACTCOMPONENTQTYCTRL ---
CREATE TABLE CONTRACTCOMPONENTQTYCTRL
(
	CONTRACT_ID NUMBER NOT NULL,
	GARMENTQTYCONTROL VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT YN_VALIDATIONFIELD447 CHECK (GARMENTQTYCONTROL IN ('Y','N')),
	NONGARMENTQTYCONTROL VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT YN_VALIDATIONFIELD448 CHECK (NONGARMENTQTYCONTROL IN 	('Y','N')),
	SYSTEMUSER_ID NUMBER NOT NULL,
	TIMESTAMP DATE NOT NULL
);

ALTER TABLE CONTRACTCOMPONENTQTYCTRL ADD CONSTRAINT XPKCONTRACTCOMPONENTQTYCONTROL PRIMARY KEY (CONTRACT_ID);

ALTER TABLE CONTRACTCOMPONENTQTYCTRL ADD CONSTRAINT CONTRACTCOMPONENTQTYCTRL_CO FOREIGN KEY (CONTRACT_ID)
REFERENCES CONTRACT (CONTRACT_ID) ON DELETE CASCADE;

--- CONTRACTCUSTOMER ---
ALTER TABLE CONTRACTCUSTOMER ADD (GARMENTQTYCONTROL VARCHAR2(1) DEFAULT 'N' NOT NULL
				CONSTRAINT YN_VALIDATIONFIELD449 CHECK (GARMENTQTYCONTROL IN ('Y','N')),
				  NONGARMENTQTYCONTROL VARCHAR2(1) DEFAULT 'N' NOT NULL
				CONSTRAINT YN_VALIDATIONFIELD450 CHECK (NONGARMENTQTYCONTROL IN ('Y','N')));

--- CONTRACTPRODUCTORDERDELIVERY ---
ALTER TABLE CONTRACTPRODUCTORDERDELIVERY ADD (QUANTITYCONTROL NUMBER DEFAULT 0 NOT NULL
					CONSTRAINT QUANTITYCONTROL_VALID1 CHECK (QUANTITYCONTROL IN (0,1,2)));

COMMENT ON COLUMN CONTRACTPRODUCTORDERDELIVERY.QUANTITYCONTROL IS '0 = not set
1 = unlocked
2 = locked';