CREATE TABLE ZH_WORDS (
  ID NUMBER(10) NOT NULL, 
  VALUE VARCHAR2(4000) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL,  
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  ORGANIZATION_ID VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_WORDS CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_WORDS DROP CONSTRAINT CHECK_BIRT_VALUE
/
ALTER TABLE ZH_WORDS DROP CONSTRAINT CHECK_NEW_STRUCTURE_VALUE
/
ALTER TABLE ZH_WORDS ADD CONSTRAINT CHECK_10848 CHECK ("IS_ACTIVE"='N' OR "IS_ACTIVE"='Y')
/
ALTER TABLE ZH_WORDS ADD CONSTRAINT WORDS_PK PRIMARY KEY (ID)
/
ALTER TABLE ZH_WORDS ADD BIRT VARCHAR2(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE ZH_WORDS ADD CONSTRAINT CHECK_BIRT_VALUE CHECK ("BIRT" IN ('Y', 'N') )
/
CREATE SEQUENCE SEQ_ZH_WORDS_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_LANGUAGE (
  ID NUMBER(10) NOT NULL, 
  SHORT_NAME VARCHAR2(6) NOT NULL, 
  LANGUAGE_ISO VARCHAR2(5) NOT NULL, 
  COUNTRY_CODE VARCHAR2(2) NOT NULL, 
  NAME VARCHAR2(120) NOT NULL, 
  DESCRIPTION VARCHAR2(510) NOT NULL, 
  HELP VARCHAR2(2000) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_LANGUAGE CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_LANGUAGE ADD CONSTRAINT CHECK_10862 CHECK ("IS_ACTIVE"='N' OR "IS_ACTIVE"='Y')
/
ALTER TABLE ZH_LANGUAGE ADD CONSTRAINT LANGUAGE_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_LANGUAGE_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_PROJECT (
  ID NUMBER(10) NOT NULL, 
  NAME VARCHAR2(120) NOT NULL, 
  DESCRIPTION VARCHAR2(510) NOT NULL, 
  HELP VARCHAR2(2000) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_PROJECT CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_PROJECT ADD CONSTRAINT CHECK_10946 CHECK (("IS_ACTIVE"='N' OR "IS_ACTIVE"='Y'))
/
ALTER TABLE ZH_PROJECT ADD CONSTRAINT PROJECT_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_PROJECT_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_REPOSITORY (
  ID NUMBER(10) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  IS_PUBLIC VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  WEB_HOOK VARCHAR2(120) NOT NULL, 
  FRONT_PATH VARCHAR2(300) NOT NULL, 
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL, 
  DEFAULT_LANGUAGE NUMBER(10) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_REPOSITORY CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_REPOSITORY DROP CONSTRAINT REPOSITORY_LANGUAGE_FK
/
ALTER TABLE ZH_REPOSITORY DROP COLUMN NEW_STRUCTURE
/
ALTER TABLE ZH_REPOSITORY DROP COLUMN WORDS_PATH
/
ALTER TABLE ZH_REPOSITORY DROP COLUMN MESSAGES_FILE
/
ALTER TABLE ZH_REPOSITORY DROP COLUMN MESSAGES_STRUCTURE
/
ALTER TABLE ZH_REPOSITORY ADD CONSTRAINT CHECK_10953 CHECK (("IS_ACTIVE" IN ('Y', 'N')))
/
ALTER TABLE ZH_REPOSITORY ADD CONSTRAINT CHECK_10954 CHECK (("IS_PUBLIC" IN ('Y', 'N')))
/
ALTER TABLE ZH_REPOSITORY ADD CONSTRAINT REPOSITORY_PK PRIMARY KEY (ID)
/
ALTER TABLE ZH_REPOSITORY ADD CONSTRAINT REPOSITORY_LANGUAGE_FK FOREIGN KEY (DEFAULT_LANGUAGE) REFERENCES ZH_LANGUAGE (ID)
/
ALTER TABLE ZH_REPOSITORY ADD NEW_STRUCTURE VARCHAR(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE ZH_REPOSITORY ADD WORDS_PATH VARCHAR(300)
/
ALTER TABLE ZH_REPOSITORY ADD MESSAGES_FILE VARCHAR(300)
/
ALTER TABLE ZH_REPOSITORY ADD MESSAGES_STRUCTURE VARCHAR(300)
/
ALTER TABLE ZH_REPOSITORY ADD CONSTRAINT CHECK_NEW_STRUCTURE_VALUE CHECK ("NEW_STRUCTURE" IN ('Y', 'N') )
/
CREATE UNIQUE INDEX WEB_HOOK_UK ON ZH_REPOSITORY (WEB_HOOK)
/
CREATE SEQUENCE SEQ_ZH_REPOSITORY_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_REPOSITORY_LANGUAGE (
  ID NUMBER(10) NOT NULL, 
  LANGUAGE_ID NUMBER(10) NOT NULL, 
  REPOSITORY_ID NUMBER(10) NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_REPOSIT_LANG CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE DROP CONSTRAINT LANG_REPOSITORY_LANGUAGE_FK
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE DROP CONSTRAINT LANG_REPOSITORY_REPOSITORY_FK
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE DROP CONSTRAINT LANGUAGE_REPOSITORY_PK
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE ADD CONSTRAINT LANG_REPOSITORY_LANGUAGE_FK FOREIGN KEY (LANGUAGE_ID) REFERENCES ZH_LANGUAGE (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE ADD CONSTRAINT LANG_REPOSITORY_REPOSITORY_FK FOREIGN KEY (REPOSITORY_ID) REFERENCES ZH_REPOSITORY (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_REPOSITORY_LANGUAGE ADD CONSTRAINT LANGUAGE_REPOSITORY_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_REPOSITORY_LANGUAGE_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_PROJECT_REPOSITORY (
  ID NUMBER(10) NOT NULL, 
  PROJECT_ID NUMBER(10) NOT NULL, 
  REPOSITORY_ID NUMBER(10) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_PROJ_REPOSIT CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_PROJECT_REPOSITORY DROP CONSTRAINT PRJ_REP_PROJECT_FK
/
ALTER TABLE ZH_PROJECT_REPOSITORY DROP CONSTRAINT PRJ_REP_REPOSITORY_FK
/
ALTER TABLE ZH_PROJECT_REPOSITORY DROP CONSTRAINT PRJ_REP_PK
/
ALTER TABLE ZH_PROJECT_REPOSITORY ADD CONSTRAINT CHECK_11088 CHECK (IS_ACTIVE IN ('Y', 'N'))
/
ALTER TABLE ZH_PROJECT_REPOSITORY ADD CONSTRAINT PRJ_REP_PROJECT_FK FOREIGN KEY (PROJECT_ID) REFERENCES ZH_PROJECT (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_PROJECT_REPOSITORY ADD CONSTRAINT PRJ_REP_REPOSITORY_FK FOREIGN KEY (REPOSITORY_ID) REFERENCES ZH_REPOSITORY (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_PROJECT_REPOSITORY ADD CONSTRAINT PRJ_REP_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_PROJECT_REPOSITORY_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_WORDS_REPOSITORY (
  WORDS_ID NUMBER(10) NOT NULL, 
  REPOSITORY_ID NUMBER(10) NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL, 
  ID NUMBER(10) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_WORDS_REPOSIT CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_WORDS_REPOSITORY DROP CONSTRAINT WORDS_REPOSITORY_REPOSITORY_FK
/
ALTER TABLE ZH_WORDS_REPOSITORY DROP CONSTRAINT WORDS_REPOSITORY_WORDS_FK
/
ALTER TABLE ZH_WORDS_REPOSITORY DROP CONSTRAINT WORDS_REPOSITORY_PK
/
ALTER TABLE ZH_WORDS_REPOSITORY ADD CONSTRAINT CHECK_11096 CHECK (IS_ACTIVE IN ('Y', 'N'))
/
ALTER TABLE ZH_WORDS_REPOSITORY ADD CONSTRAINT WORDS_REPOSITORY_REPOSITORY_FK FOREIGN KEY (REPOSITORY_ID) REFERENCES ZH_REPOSITORY (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_WORDS_REPOSITORY ADD CONSTRAINT WORDS_REPOSITORY_WORDS_FK FOREIGN KEY (WORDS_ID) REFERENCES ZH_WORDS (ID) ON DELETE CASCADE
/
ALTER TABLE ZH_WORDS_REPOSITORY ADD CONSTRAINT WORDS_REPOSITORY_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_WORDS_REPOSITORY_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE ZH_WORDS_TRL (
  ID NUMBER(10) NOT NULL, 
  WORDS_ID NUMBER(10) NOT NULL, 
  LANGUAGE_ID NUMBER(10) NOT NULL, 
  VALUE VARCHAR2(4000) NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'T' NOT NULL, 
  PRIMARY_VALUE VARCHAR2(4000) NOT NULL, 
  IS_ACTIVE VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  CREATED DATE NOT NULL, 
  UPDATED DATE NOT NULL, 
  CREATED_BY VARCHAR2(255) NOT NULL, 
  UPDATED_BY VARCHAR2(255) NOT NULL,
  NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ZH_WORDS_TRL CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO        DATE                  			NULL,
  DTULTATU          DATE                  			NULL,
  NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 		NULL,
  NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
  CDOPERULTATU      VARCHAR2(12)    DEFAULT '1'
)
/
ALTER TABLE ZH_WORDS_TRL DROP CONSTRAINT WORDS_TRL_LANGUAGE_FK
/
ALTER TABLE ZH_WORDS_TRL DROP CONSTRAINT WORDS_TRL_WORDS_FK
/
ALTER TABLE ZH_WORDS_TRL DROP CONSTRAINT WORDS_TRL_PK
/
ALTER TABLE ZH_WORDS_TRL DROP CONSTRAINT CHECK_STATUS_ZH_WORDS_TRL
/
ALTER TABLE ZH_WORDS_TRL ADD CONSTRAINT CHECK_11107 CHECK (("IS_ACTIVE"='N' OR "IS_ACTIVE"='Y'))
/
ALTER TABLE ZH_WORDS_TRL ADD CONSTRAINT CHECK_STATUS_ZH_WORDS_TRL CHECK (STATUS IN ('A', 'T'))
/
ALTER TABLE ZH_WORDS_TRL ADD CONSTRAINT WORDS_TRL_LANGUAGE_FK FOREIGN KEY (LANGUAGE_ID) REFERENCES ZH_LANGUAGE (ID)
/
ALTER TABLE ZH_WORDS_TRL ADD CONSTRAINT WORDS_TRL_WORDS_FK FOREIGN KEY (WORDS_ID) REFERENCES ZH_WORDS (ID)
/
ALTER TABLE ZH_WORDS_TRL ADD CONSTRAINT WORDS_TRL_PK PRIMARY KEY (ID)
/
CREATE SEQUENCE SEQ_ZH_WORDS_TRL_ID START WITH 1 MINVALUE 1 INCREMENT BY 1
/