--order 502663      
      /*
      CHANGE REPORT for Table PRODUCTCONVERSION
          - Adding a new relationship PRODUCTCONVERSION_CUSTOMER_LIN
          WARNING : Create FK statement may fail (existing data may violate the new FK rules: adding a new FK PRODUCTCONVERSION_CUSTOMER_LIN of table PRODUCTCONVERSION, which references table CUSTOMER_LINK).
          - Changing definition of relation PRODUCTCONVERSION_PRODUCT_ID
          - Adding a new relationship PRODUCTCONVERSION_SOURCEPRODUC
          WARNING : Create FK statement may fail (existing data may violate the new FK rules: adding a new FK PRODUCTCONVERSION_SOURCEPRODUC of table PRODUCTCONVERSION, which references table PRODUCT).
          - Adding column CUSTOMER_LINK_ID
          - Adding column CUSTOMERSELECTION
          - Renaming column PRODUCT_ID to SOURCEPRODUCT_ID
          - change unknown attribute from 2 to 8, change unknown attribute from 2 to 8 of column SOURCEPRODUCT_ID
          - Adding column DESTINATIONPRODUCT_ID
          - Adding index XIF5PRODUCTCONVERSION
          - Adding index XIF6PRODUCTCONVERSION
          - Adding index XIF7PRODUCTCONVERSION
          WARNING : Recreating Table PRODUCTCONVERSION based on the ERwin source model. Any differences marked 'Ignore' in the compare list will be recreated based on the ERwin source model.
          - index XIF1PRODUCTCONVERSION will be dropped as a side effect. 
          - index XIF2PRODUCTCONVERSION will be dropped as a side effect. 
          - index XIF3PRODUCTCONVERSION will be dropped as a side effect. 
          - index XPKPRODUCTCONVERSION will be dropped as a side effect. 
          - foreign key PRODUCTCONVERSION_PRODUCT_ID of table PRODUCTCONVERSION will be dropped as a side effect. 
          - foreign key PRODUCTCONVERSION_PRODUCTLISTP of table PRODUCTCONVERSION will be dropped as a side effect. 
          - foreign key PRODUCTCONVERSION_SIZEDEFINITI of table PRODUCTCONVERSION will be dropped as a side effect. 
      */

DROP INDEX XIF1PRODUCTCONVERSION;
DROP INDEX XIF2PRODUCTCONVERSION;
DROP INDEX XIF3PRODUCTCONVERSION;

ALTER TABLE PRODUCTCONVERSION DROP CONSTRAINT PRODUCTCONVERSION_PRODUCTLISTP;
ALTER TABLE PRODUCTCONVERSION DROP CONSTRAINT PRODUCTCONVERSION_PRODUCT_ID;
ALTER TABLE PRODUCTCONVERSION DROP CONSTRAINT PRODUCTCONVERSION_SIZEDEFINITI;

ALTER TABLE PRODUCTCONVERSION RENAME COLUMN PRODUCT_ID TO SOURCEPRODUCT_ID;
ALTER TABLE PRODUCTCONVERSION DROP COLUMN SIZEDEFINITION_ID;
ALTER TABLE PRODUCTCONVERSION DROP COLUMN PRODUCTLISTPERCUSTOMER_ID;

CREATE INDEX XIF1PRODUCTCONVERSION ON PRODUCTCONVERSION
(
	SOURCEPRODUCT_ID
);


ALTER TABLE PRODUCTCONVERSION ADD (CUSTOMER_LINK_ID NUMBER NOT NULL);

ALTER TABLE PRODUCTCONVERSION ADD (CUSTOMERSELECTION NUMBER DEFAULT 0 NOT NULL
					CONSTRAINT CustomerSelection_valid
						CHECK (CUSTOMERSELECTION IN (0,1,2)));

COMMENT ON COLUMN PRODUCTCONVERSION.CUSTOMERSELECTION IS '0 = Customer
1 = Debtor
2 = Master Account';

ALTER TABLE PRODUCTCONVERSION ADD (DESTINATIONPRODUCT_ID NUMBER NOT NULL);

CREATE INDEX XIF2PRODUCTCONVERSION ON PRODUCTCONVERSION
(
	CUSTOMER_LINK_ID	ASC
);

      
      /*
      ACTION is CREATE Table PRODUCTCONVERSIONLINE
      */
CREATE SEQUENCE SEQ_PRODUCTCONVERSIONLINE
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODUCTCONVERSIONLINE (
       PRODUCTCONVERSIONLINE_ID NUMBER NOT NULL,
       PRODUCTCONVERSION_ID NUMBER NOT NULL,
       SOURCEPLPC_ID        NUMBER NOT NULL,
       DESTINATIONPLPC_ID   NUMBER NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE UNIQUE INDEX XAK1PRODUCTCONVERSIONLINE ON PRODUCTCONVERSIONLINE
(
       PRODUCTCONVERSION_ID           ,
       SOURCEPLPC_ID                  
);

CREATE INDEX XIF1PRODUCTCONVERSIONLINE ON PRODUCTCONVERSIONLINE
(
       PRODUCTCONVERSION_ID           ASC
);

CREATE INDEX XIF2PRODUCTCONVERSIONLINE ON PRODUCTCONVERSIONLINE
(
       SOURCEPLPC_ID                  ASC
);

CREATE INDEX XIF3PRODUCTCONVERSIONLINE ON PRODUCTCONVERSIONLINE
(
       DESTINATIONPLPC_ID             ASC
);


ALTER TABLE PRODUCTCONVERSIONLINE
       ADD  ( CONSTRAINT XPKPRODUCTCONVERSIONLINE PRIMARY KEY (
              PRODUCTCONVERSIONLINE_ID) ) ;

      
      /*
      ACTION is CREATE Table PRODUCTCONVERSIONSIZE
      */
CREATE SEQUENCE SEQ_PRODUCTCONVERSIONSIZE
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODUCTCONVERSIONSIZE (
       PRODUCTCONVERSIONSIZE_ID NUMBER NOT NULL,
       PRODUCTCONVERSION_ID NUMBER NOT NULL,
       SOURCESIZEDEFINITION_ID NUMBER NOT NULL,
       DESTINATIONSIZEDEFINITION_ID NUMBER NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE UNIQUE INDEX XAK1PRODUCTCONVERSIONSIZE ON PRODUCTCONVERSIONSIZE
(
       PRODUCTCONVERSION_ID           ,
       SOURCESIZEDEFINITION_ID        
);

CREATE INDEX XIF1PRODUCTCONVERSIONSIZE ON PRODUCTCONVERSIONSIZE
(
       PRODUCTCONVERSION_ID           ASC
);

CREATE INDEX XIF2PRODUCTCONVERSIONSIZE ON PRODUCTCONVERSIONSIZE
(
       SOURCESIZEDEFINITION_ID        ASC
);

CREATE INDEX XIF3PRODUCTCONVERSIONSIZE ON PRODUCTCONVERSIONSIZE
(
       DESTINATIONSIZEDEFINITION_ID   ASC
);


ALTER TABLE PRODUCTCONVERSIONSIZE
       ADD  ( CONSTRAINT XPKPRODUCTCONVERSIONSIZE PRIMARY KEY (
              PRODUCTCONVERSIONSIZE_ID) ) ;





ALTER TABLE PRODUCTCONVERSIONLINE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONLINE_DESTINAT
              FOREIGN KEY (DESTINATIONPLPC_ID)
                             REFERENCES PRODUCTLISTPERCUSTOMER ) ;


ALTER TABLE PRODUCTCONVERSIONLINE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONLINE_SOURCEPL
              FOREIGN KEY (SOURCEPLPC_ID)
                             REFERENCES PRODUCTLISTPERCUSTOMER
                             ON DELETE CASCADE ) ;


ALTER TABLE PRODUCTCONVERSIONLINE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONLINE_PRODUCTC
              FOREIGN KEY (PRODUCTCONVERSION_ID)
                             REFERENCES PRODUCTCONVERSION
                             ON DELETE CASCADE ) ;


ALTER TABLE PRODUCTCONVERSIONSIZE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONSIZE_DESTINAT
              FOREIGN KEY (DESTINATIONSIZEDEFINITION_ID)
                             REFERENCES SIZEDEFINITION ) ;


ALTER TABLE PRODUCTCONVERSIONSIZE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONSIZE_SOURCESI
              FOREIGN KEY (SOURCESIZEDEFINITION_ID)
                             REFERENCES SIZEDEFINITION
                             ON DELETE CASCADE ) ;


ALTER TABLE PRODUCTCONVERSIONSIZE
       ADD  ( CONSTRAINT PRODUCTCONVERSIONSIZE_PRODUCTC
              FOREIGN KEY (PRODUCTCONVERSION_ID)
                             REFERENCES PRODUCTCONVERSION
                             ON DELETE CASCADE ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_DESTINATIONP
              FOREIGN KEY (DESTINATIONPRODUCT_ID)
                             REFERENCES PRODUCT ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_SOURCEPRODUC
              FOREIGN KEY (SOURCEPRODUCT_ID)
                             REFERENCES PRODUCT
                             ON DELETE CASCADE ) ;


ALTER TABLE PRODUCTCONVERSION
       ADD  ( CONSTRAINT PRODUCTCONVERSION_CUSTOMER_LIN
              FOREIGN KEY (CUSTOMER_LINK_ID)
                             REFERENCES CUSTOMER_LINK ) ;







