--order 502663      
      /*
      ACTION is CREATE Table PRODUCTCONVERSION
      */

CREATE SEQUENCE SEQ_PRODUCTCONVERSION
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODUCTCONVERSION (
       PRODUCTCONVERSION_ID NUMBER NOT NULL,
       PRODUCT_ID           NUMBER NOT NULL,
       SIZEDEFINITION_ID    NUMBER NOT NULL,
       STARTDATE            DATE NOT NULL,
       STATUS               NUMBER DEFAULT 0 NOT NULL
                                   CONSTRAINT StatusProductConversion_valid
                                          CHECK (STATUS IN (0, 1, 2)),
       PRODUCTLISTPERCUSTOMER_ID NUMBER NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

COMMENT ON COLUMN PRODUCTCONVERSION.STATUS IS '0 = New
1 = Completed
2 = Cancelled
';
CREATE INDEX XIF1PRODUCTCONVERSION ON PRODUCTCONVERSION
(
       PRODUCT_ID                     ASC
);

CREATE INDEX XIF2PRODUCTCONVERSION ON PRODUCTCONVERSION
(
       SIZEDEFINITION_ID              ASC
);

CREATE INDEX XIF3PRODUCTCONVERSION ON PRODUCTCONVERSION
(
       PRODUCTLISTPERCUSTOMER_ID      ASC
);


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT XPKPRODUCTCONVERSION PRIMARY KEY (
              PRODUCTCONVERSION_ID) ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_PRODUCTLISTP
              FOREIGN KEY (PRODUCTLISTPERCUSTOMER_ID)
                             REFERENCES PRODUCTLISTPERCUSTOMER ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_SIZEDEFINITI
              FOREIGN KEY (SIZEDEFINITION_ID)
                             REFERENCES SIZEDEFINITION ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_PRODUCT_ID
              FOREIGN KEY (PRODUCT_ID)
                             REFERENCES PRODUCT ) ;



