ALTER TABLE DEPLOY ADD (PRODUCT_ID NUMBER(10) DEFAULT NULL NULL)
/
CREATE INDEX DEPLOY_PRODUCT_FK ON DEPLOY (PRODUCT_ID)
/
ALTER TABLE DEPLOY ADD (PRODUCT_VERSION_ID NUMBER(10) DEFAULT NULL NULL)
/
CREATE INDEX DEPLOY_PRODUCT_VERSION_FK ON DEPLOY (PRODUCT_VERSION_ID)
/
ALTER TABLE DEPLOY ADD (DEPLOY_DATE DATE DEFAULT SYSDATE NULL)
/

CREATE TABLE PRODUCT_VERSION
  (
    ID              NUMBER(10) NOT NULL,
    PRODUCT_ID      NUMBER(10) NOT NULL,
    VERSION         NUMBER(10) NOT NULL,
    REVISION        NUMBER(10) NOT NULL,
    BUILD           NUMBER(10) NOT NULL,
    IS_REVISION     VARCHAR2(1) DEFAULT 'N' NOT NULL,
    IS_BUILD        VARCHAR2(1) DEFAULT 'N' NOT NULL,
    IS_LTS          VARCHAR2(1) DEFAULT 'N' NOT NULL,
    IS_ACTIVE       VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    ORGANIZATION_ID NUMBER(10) NOT NULL,
    CREATED         DATE DEFAULT SYSDATE NOT NULL,
    CREATED_BY      NUMBER(10) NOT NULL,
    UPDATED         DATE DEFAULT SYSDATE NOT NULL,
    UPDATED_BY      NUMBER(10) NOT NULL,
    CONSTRAINT PRODUCT_VERSION_PK PRIMARY KEY(ID)
  )
/
CREATE INDEX PRODUCT_VERSION_ORG_FK ON PRODUCT_VERSION (ORGANIZATION_ID)
/
CREATE INDEX PRODUCT_VERSION_PRODUCT_FK ON PRODUCT_VERSION (PRODUCT_ID)
/
CREATE INDEX PRODUCT_VERSION_USER_FK1 ON PRODUCT_VERSION (CREATED_BY)
/
CREATE INDEX PRODUCT_VERSION_USER_FK2 ON PRODUCT_VERSION (UPDATED_BY)
/
CREATE SEQUENCE PRODUCT_VERSION_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
/

ALTER TABLE PRODUCT_SERVER ADD (PATH VARCHAR2(1000) DEFAULT NULL NULL)
/

ALTER TABLE DEPLOY ADD CONSTRAINT DEPLOY_PRODUCT_FK FOREIGN KEY (PRODUCT_ID) REFERENCES PRODUCT (ID)
/
ALTER TABLE DEPLOY ADD CONSTRAINT DEPLOY_PRODUCT_VERSION_FK FOREIGN KEY (PRODUCT_VERSION_ID) REFERENCES PRODUCT_VERSION (ID)
/
ALTER TABLE PRODUCT_VERSION ADD CONSTRAINT PRODUCT_VERSION_ORG_FK FOREIGN KEY (ORGANIZATION_ID) REFERENCES ORGANIZATION (ID)
/
ALTER TABLE PRODUCT_VERSION ADD CONSTRAINT PRODUCT_VERSION_PRODUCT_FK FOREIGN KEY (PRODUCT_ID) REFERENCES PRODUCT (ID)
/
ALTER TABLE PRODUCT_VERSION ADD CONSTRAINT PRODUCT_VERSION_USER_FK1 FOREIGN KEY (CREATED_BY) REFERENCES ZH_USER (ID)
/
ALTER TABLE PRODUCT_VERSION ADD CONSTRAINT PRODUCT_VERSION_USER_FK2 FOREIGN KEY (UPDATED_BY) REFERENCES ZH_USER (ID)
/
