drop table ACLENTRIES_2  IF EXISTS;
drop table ACLS_2  IF EXISTS;
drop table ACLS_WITH_RESOURCE_1  IF EXISTS;
drop table ALIASES_1  IF EXISTS;
drop table CATALOGVERSION_2  IF EXISTS;
drop table COMPLETEDPUBLISHTABLE_2  IF EXISTS;
drop table COMPLETEDRESULTTABLE_3  IF EXISTS;
drop table COMPLETEDTABLE_4  IF EXISTS;
drop table DRESULT_2  IF EXISTS;
drop table DYNAMICRESULT_1  IF EXISTS;
drop table EXTENDACLENTRIES_2  IF EXISTS;
drop table FOLDERS_3  IF EXISTS;
drop table GROUPPROFILES_1  IF EXISTS;
drop table GROUPS_1  IF EXISTS;
drop table GUPROFILES_1  IF EXISTS;
drop table NODES_3  IF EXISTS;
drop table REPORTVERSION_2  IF EXISTS;
drop table RESOURCEMAP_1  IF EXISTS;
drop table RESOURCENODES_3  IF EXISTS;
drop table RESULTVERSION_2  IF EXISTS;
drop table RESULT_2  IF EXISTS;
drop table RGPROFILES_1  IF EXISTS;
drop table ROLEPROFILES_2  IF EXISTS;
drop table ROLES_2  IF EXISTS;
drop table SCHDLASTEXETIME_1  IF EXISTS;
drop table TBL_IDGENRATOR_JINFONET  IF EXISTS;
drop table TRIGGERS_1  IF EXISTS;
drop table UPDATEDETAILS_1  IF EXISTS;
drop table USERPROFILES_2  IF EXISTS;
drop table USERS_3  IF EXISTS;
drop table VERSIONNODES_2  IF EXISTS;
drop table TASKCONTEXT  IF EXISTS;
drop table DYNAMICNODE_2  IF EXISTS;

CREATE TABLE TBL_IDGENRATOR_JINFONET(TF_NAME VARCHAR(64) NOT NULL PRIMARY KEY,NEXT_ID INTEGER NOT NULL);
CREATE TABLE UPDATEDETAILS_1(UPDATE_ITEM VARCHAR(32) NOT NULL PRIMARY KEY,UPDATE_STATE BOOLEAN NOT NULL);
CREATE TABLE NODES_3(ID INTEGER NOT NULL,NAME VARCHAR(64) NOT NULL,CREATORNAME VARCHAR(32) NOT NULL,CREATETIME BIGINT NOT NULL,PARENTID INTEGER NOT NULL,NODETYPE TINYINT NOT NULL,ACLID INTEGER,DESCRIPTION VARCHAR(256), ENABLELINKEDCAT BOOLEAN, LINKEDCAT VARCHAR(256), USEINHERITED BOOLEAN);
CREATE TABLE FOLDERS_3(ID INTEGER NOT NULL,REALPATH VARCHAR(256),OWNERNAME VARCHAR(32),MAXVERSIONAMOUNT INTEGER NOT NULL,ARCHIVENEWVERSION BOOLEAN NOT NULL,ENABLEARCHIVEPOLICY BOOLEAN NOT NULL,IS_SHARED BOOLEAN NOT NULL,ENABLEDYNAMICRESOURCE BOOLEAN NOT NULL);
CREATE TABLE RESOURCENODES_3(ID INTEGER NOT NULL,RESOURCETYPE TINYINT NOT NULL,REALPATH VARCHAR(256),MAXVERSIONAMOUNT INTEGER NOT NULL,ARCHIVENEWVERSION BOOLEAN NOT NULL,ENABLEARCHIVEPOLICY BOOLEAN NOT NULL,PROFILENAME VARCHAR(256));
CREATE TABLE VERSIONNODES_2(ID INTEGER NOT NULL,RESOURCEID INTEGER NOT NULL,VERSIONNUMBER INTEGER NOT NULL,EXPIRATIONTIME BIGINT NOT NULL);
CREATE TABLE ALIASES_1(ID INTEGER NOT NULL,PRINCIPAL_NAME VARCHAR(128) NOT NULL,PRINCIPAL_TYPE TINYINT NOT NULL,ALIAS_NAME VARCHAR(256) NOT NULL,PARENT_NAME VARCHAR(256),MAP_RESOURCE VARCHAR(256) NOT NULL,HIDDEN BOOLEAN NOT NULL,CONSTRAINT SYS_CT_54 UNIQUE(ID));
CREATE TABLE CATALOGVERSION_2(VERSIONNUMBER INTEGER NOT NULL,VERSIONNAME VARCHAR(128),RESOURCEID INTEGER NOT NULL,CREATOR VARCHAR(128),CREATEDTIME BIGINT NOT NULL,MODIFIER VARCHAR(128),MODIFIEDTIME BIGINT NOT NULL,CATALOGFILE VARCHAR(128) NOT NULL,ID BIGINT NOT NULL,CONSTRAINT SYS_CT_57 UNIQUE(ID));
CREATE TABLE REPORTVERSION_2(VERSIONNUMBER INTEGER NOT NULL,VERSIONNAME VARCHAR(128),RESOURCEID INTEGER NOT NULL,CREATOR VARCHAR(128),CREATETIME BIGINT NOT NULL,MODIFIER VARCHAR(128),MODIFIEDTIME BIGINT NOT NULL,REPORTFILE VARCHAR(128) NOT NULL,ID BIGINT NOT NULL,CONSTRAINT SYS_CT_60 UNIQUE(RESOURCEID,ID));
CREATE TABLE RESULTVERSION_2(ID BIGINT NOT NULL,VERSIONNUMBER INTEGER NOT NULL,VERSIONNAME VARCHAR(128) NOT NULL,RESOURCEID INTEGER NOT NULL,CREATOR VARCHAR(128),CREATEDTIME BIGINT NOT NULL,MODIFIER VARCHAR(128),MODIFIEDTIME BIGINT NOT NULL,CATALOGVERNUM INTEGER NOT NULL,CATALOGRESNUM INTEGER NOT NULL,REPORTVERNUM INTEGER NOT NULL,REPORTRESNUM INTEGER NOT NULL,PARAMFILE VARCHAR(128),RESULTFILE VARCHAR(128) NOT NULL,RESULTFMTS BIGINT NOT NULL,LAUNCHTYPE INTEGER NOT NULL,TASKID VARCHAR(128),EXPIRATIONTIME BIGINT NOT NULL,EXPIRE BOOLEAN NOT NULL,EXPIREATIONMETHOD INTEGER,SPECIFIEDFOLDER VARCHAR(128),REPORTAMOUNT INTEGER,CONSTRAINT SYS_CT_63 UNIQUE(ID,RESOURCEID));
CREATE TABLE RESULT_2(RESOURCEID BIGINT NOT NULL,VERSIONNUMBER BIGINT NOT NULL,REPORT VARCHAR(128) NOT NULL,REPORTDISPLAYNAME VARCHAR(128),RESULT VARCHAR(128) NOT NULL,VIEWEDFORMATS BIGINT,PLSRESULTFMTS BIGINT,SECCONSTRAINTFMTS BIGINT);
CREATE TABLE DYNAMICNODE_2(NAME VARCHAR(128) NOT NULL,ROOT VARCHAR(128) NOT NULL,REALPATH VARCHAR(256) NOT NULL,NODETYPE TINYINT NOT NULL,ENABLEARCHIVEPOLICY BOOLEAN NOT NULL,DELETED BOOLEAN NOT NULL,ACLID INTEGER,DESCRIPTION VARCHAR(256),MAXVERSIONAMOUNT INTEGER,ENABLELINKEDCAT BOOLEAN,LINKEDCAT VARCHAR(256),USEINHERITED BOOLEAN);
CREATE TABLE DYNAMICRESULT_1(ID INTEGER NOT NULL,REPORTNAME VARCHAR(128) NOT NULL,VERSIONNUMBER INTEGER NOT NULL,CREATOR VARCHAR(128) NOT NULL,CREATEDTIME BIGINT NOT NULL,CATALOGVERNUM INTEGER NOT NULL,CATALOGRESNUM INTEGER NOT NULL,REPORTVERNUM INTEGER NOT NULL,REPORTRESNUM INTEGER NOT NULL,PARAMFILE VARCHAR(128),RESULTFILE VARCHAR(128) NOT NULL,RESULTFMTS BIGINT NOT NULL,LAUNCHTYPE INTEGER NOT NULL,TASKID VARCHAR(128),EXPIRATIONTIME BIGINT NOT NULL,EXPIRE BOOLEAN NOT NULL,EXPIRATIONMETHOD INTEGER,REPORTAMOUNT INTEGER);
CREATE TABLE DRESULT_2(REPORTSET VARCHAR(128),VERSIONNUMBER BIGINT NOT NULL,REPORT VARCHAR(128) NOT NULL,REPORTDISPLAYNAME VARCHAR(128),RESULT VARCHAR(128) NOT NULL,VIEWEDFORMATS BIGINT,PLSRESULTFMTS BIGINT,SECCONSTRAINTFMTS BIGINT);
CREATE TABLE RESOURCEMAP_1(RESOURCEID INTEGER NOT NULL,RESOURCENAME VARCHAR(128) NOT NULL,RESOURCETYPE TINYINT NOT NULL);
CREATE TABLE USERS_3(NAME VARCHAR(32) NOT NULL PRIMARY KEY,FULL_NAME VARCHAR(128),DESCRIPTION VARCHAR(128),EMAIL VARCHAR(128),CREATE_TIME BIGINT NOT NULL,USER_PSWD VARCHAR(128),BUILDIN BOOLEAN NOT NULL,ENABLE BOOLEAN NOT NULL,MIN_PS_LENGTH INTEGER,LAST_MODIFY_TIME BIGINT,NEVER_EXPIRE BOOLEAN NOT NULL,EXPIRE_TIME INTEGER,ACCOUNT_DISABLE BOOLEAN NOT NULL,ACCESS_EVENT_SUC BOOLEAN NOT NULL,ACCESS_EVENT_FAIL BOOLEAN NOT NULL,MANAGEMENT_EVENT_SUC BOOLEAN NOT NULL,MANAGEMENT_EVENT_FAIL BOOLEAN NOT NULL,NO_AUDIT BOOLEAN NOT NULL,AUTH_TYPE INTEGER NOT NULL,LDAP_TYPE INTEGER);
CREATE TABLE USERPROFILES_2(USER_NAME VARCHAR(32),ROLE_NAME VARCHAR(32));
CREATE TABLE ROLES_2(NAME VARCHAR(32) NOT NULL PRIMARY KEY,BUILDIN BOOLEAN NOT NULL,DESCRIPTION VARCHAR(32),ROLE_TYPE INTEGER NOT NULL);
CREATE TABLE ACLS_2(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(64) NOT NULL,CREATE_NAME VARCHAR(32) NOT NULL,CREATE_TIME BIGINT);
CREATE TABLE ACLENTRIES_2(ENTRY_ID INTEGER NOT NULL PRIMARY KEY,ACL_ID INTEGER NOT NULL,PRINCIPAL_TYPE TINYINT NOT NULL,PRINCIPAL_NAME VARCHAR(64) NOT NULL,IS_POSITIVE BOOLEAN NOT NULL,PERMISSIONS INTEGER NOT NULL);
CREATE TABLE ROLEPROFILES_2(ROLE_NAME VARCHAR(32),SUB_ROLE_NAME VARCHAR(32));
CREATE TABLE GROUPS_1(NAME VARCHAR(32) NOT NULL PRIMARY KEY,BUILDIN BOOLEAN NOT NULL,DESCRIPTION VARCHAR(32),GROUP_TYPE INTEGER NOT NULL);
CREATE TABLE GROUPPROFILES_1(GROUP_NAME VARCHAR(32),SUB_GROUP_NAME VARCHAR(32));
CREATE TABLE RGPROFILES_1(ROLE_NAME VARCHAR(32),GROUP_NAME VARCHAR(32));
CREATE TABLE GUPROFILES_1(GROUP_NAME VARCHAR(32),USER_NAME VARCHAR(32));
CREATE TABLE EXTENDACLENTRIES_2(PRINCIPAL_NAME VARCHAR(64) NOT NULL,PRINCIPAL_TYPE TINYINT NOT NULL,PERMISSIONS INTEGER NOT NULL,CONSTRAINT SYS_CT_86 UNIQUE(PRINCIPAL_NAME,PRINCIPAL_TYPE));
CREATE TABLE COMPLETEDTABLE_4(ID INTEGER NOT NULL,RECORDID VARCHAR(128),TASKID VARCHAR(128) NOT NULL,TASKCLASS VARCHAR(256) NOT NULL,CATFILE VARCHAR(256),RPTFILE VARCHAR(256),PARAMFILE VARCHAR(256),RESULTFILE VARCHAR(512),ERROR VARCHAR(256),ENGMSG VARCHAR(512),SUBMITTER VARCHAR(128),COMPLETEDTIME BIGINT,FORMATEXISTS INTEGER,FORMATSUCCESSFUL INTEGER,VERSIONID INTEGER,LAUNCHTYPE INTEGER,ISSUCCESSFUL BOOLEAN NOT NULL,TASKNAME VARCHAR(128),ISMISSED BOOLEAN NOT NULL,SCHEDULETRIGGER VARCHAR(80),CONDITIONSLOGIC VARCHAR(16),REPORTNAMES VARCHAR(512));
CREATE TABLE COMPLETEDPUBLISHTABLE_2(ID INTEGER NOT NULL,RECORDID VARCHAR(40) NOT NULL,SHEETNAME VARCHAR(256) NOT NULL,DISPLAYNAME VARCHAR(256),PUB_TYPE VARCHAR(64) NOT NULL);
CREATE TABLE COMPLETEDRESULTTABLE_3(PUBLISHID INTEGER NOT NULL,RECORDID VARCHAR(40) NOT NULL,PUB_TYPE VARCHAR(128) NOT NULL,STATUS INTEGER NOT NULL,DETAIL VARCHAR(256) NOT NULL);
CREATE TABLE TRIGGERS_1(TRIGGER_NAME VARCHAR(80) NOT NULL PRIMARY KEY,DESCRIPTION VARCHAR(255),TRIGGER_TYPE TINYINT NOT NULL,TRIGGER_STATE BOOLEAN NOT NULL,PREV_FIRE_TIME BIGINT,NEXT_FIRE_TIME BIGINT);
CREATE TABLE SCHDLASTEXETIME_1(TASKID VARCHAR(40) NOT NULL,LASTEXETIME BIGINT NOT NULL);
CREATE TABLE ACLS_WITH_RESOURCE_1(ID INTEGER NOT NULL PRIMARY KEY,RESOURCE_PATH VARCHAR(256) NOT NULL,VERSION_NUMBER INTEGER NOT NULL,ACL_NAME VARCHAR(64) NOT NULL,CREATE_NAME VARCHAR(32) NOT NULL,CREATE_TIME BIGINT);


CREATE CACHED TABLE TASKCONTEXT (ID INTEGER NOT NULL PRIMARY KEY,VS_RPT_NAME VARCHAR(255),VI_TSK_TYPE INTEGER,VI_TSK_STATUS INTEGER,TS_TSK_SUBMIT TIMESTAMP,TS_ENG_START TIMESTAMP,TS_ENG_EXITS TIMESTAMP,TS_TSK_COMPLETE TIMESTAMP,TC_TSK_TOTAL BIGINT,TC_TSK_WAITED BIGINT,TC_ENG_TOTAL BIGINT,TC_ENG_LOAD BIGINT,TC_ENG_EXPORT BIGINT,TC_ENG_OTHER BIGINT,TC_TSK_OTHER BIGINT,NC_RPT_PAGES BIGINT,NC_RPT_FORMATS BIGINT,NC_ENG_CONCURRENT BIGINT,NC_QUE_LENGTH BIGINT);


INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('NODES_3_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('CATALOGVERSION_2_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('REPORTVERSION_2_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('RESULTVERSION_2_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLS_2_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLENTRIES_2_ENTRY_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('COMPLETEDTABLE_4_ID',0);
INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLS_WITH_RESOURCE_1_ID',0);
