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

CREATE TABLE TBL_IDGENRATOR_JINFONET (TF_NAME VARCHAR(64) NOT NULL,NEXT_ID INTEGER NOT NULL, PRIMARY KEY(TF_NAME));
CREATE TABLE UPDATEDETAILS_1 (UPDATE_ITEM VARCHAR(32) NOT NULL,UPDATE_STATE SMALLINT NOT NULL, PRIMARY KEY(UPDATE_ITEM));
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 SMALLINT NOT NULL,ACLID INTEGER,DESCRIPTION VARCHAR(256),ENABLELINKEDCAT SMALLINT,LINKEDCAT VARCHAR(256),USEINHERITED SMALLINT);
CREATE TABLE FOLDERS_3 (ID INTEGER NOT NULL,REALPATH VARCHAR(256),OWNERNAME VARCHAR(32),MAXVERSIONAMOUNT INTEGER NOT NULL,ARCHIVENEWVERSION SMALLINT NOT NULL,ENABLEARCHIVEPOLICY SMALLINT NOT NULL,IS_SHARED SMALLINT NOT NULL,ENABLEDYNAMICRESOURCE SMALLINT NOT NULL);
CREATE TABLE RESOURCENODES_3 (ID INTEGER NOT NULL,RESOURCETYPE SMALLINT NOT NULL,REALPATH VARCHAR(256),MAXVERSIONAMOUNT INTEGER NOT NULL,ARCHIVENEWVERSION SMALLINT NOT NULL,ENABLEARCHIVEPOLICY SMALLINT 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 SMALLINT NOT NULL,ALIAS_NAME VARCHAR(256) NOT NULL,PARENT_NAME VARCHAR(256),MAP_RESOURCE VARCHAR(256) NOT NULL,HIDDEN SMALLINT NOT NULL, 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, 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, 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 SMALLINT NOT NULL,EXPIREATIONMETHOD INTEGER,SPECIFIEDFOLDER VARCHAR(128),REPORTAMOUNT INTEGER, 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 SMALLINT NOT NULL,ENABLEARCHIVEPOLICY SMALLINT NOT NULL,DELETED SMALLINT NOT NULL,ACLID INTEGER,DESCRIPTION VARCHAR(256),MAXVERSIONAMOUNT INTEGER,ENABLELINKEDCAT SMALLINT,LINKEDCAT VARCHAR(256),USEINHERITED SMALLINT);
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 SMALLINT 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 SMALLINT NOT NULL);
CREATE TABLE USERS_3 (NAME VARCHAR(32) NOT NULL,FULL_NAME VARCHAR(128),DESCRIPTION VARCHAR(128),EMAIL VARCHAR(128),CREATE_TIME BIGINT NOT NULL,USER_PSWD VARCHAR(128),BUILDIN SMALLINT NOT NULL,ENABLE SMALLINT NOT NULL,MIN_PS_LENGTH INTEGER,LAST_MODIFY_TIME BIGINT,NEVER_EXPIRE SMALLINT NOT NULL,EXPIRE_TIME INTEGER,ACCOUNT_DISABLE SMALLINT NOT NULL,ACCESS_EVENT_SUC SMALLINT NOT NULL,ACCESS_EVENT_FAIL SMALLINT NOT NULL,MANAGEMENT_EVENT_SUC SMALLINT NOT NULL,MANAGEMENT_EVENT_FAIL SMALLINT NOT NULL,NO_AUDIT SMALLINT NOT NULL,AUTH_TYPE INTEGER NOT NULL,LDAP_TYPE INTEGER, PRIMARY KEY(NAME));
CREATE TABLE USERPROFILES_2 (USER_NAME VARCHAR(32),ROLE_NAME VARCHAR(32));
CREATE TABLE ROLES_2 (NAME VARCHAR(32) NOT NULL,BUILDIN SMALLINT NOT NULL,DESCRIPTION VARCHAR(32),ROLE_TYPE INTEGER NOT NULL, PRIMARY KEY(NAME));
CREATE TABLE ACLS_2 (ID INTEGER NOT NULL,NAME VARCHAR(64) NOT NULL,CREATE_NAME VARCHAR(32) NOT NULL,CREATE_TIME BIGINT, PRIMARY KEY(ID));
CREATE TABLE ACLENTRIES_2 (ENTRY_ID INTEGER NOT NULL,ACL_ID INTEGER NOT NULL,PRINCIPAL_TYPE SMALLINT NOT NULL,PRINCIPAL_NAME VARCHAR(64) NOT NULL,IS_POSITIVE SMALLINT NOT NULL,PERMISSIONS INTEGER NOT NULL, PRIMARY KEY(ENTRY_ID));
CREATE TABLE ROLEPROFILES_2 (ROLE_NAME VARCHAR(32),SUB_ROLE_NAME VARCHAR(32));
CREATE TABLE GROUPS_1 (NAME VARCHAR(32) NOT NULL,BUILDIN SMALLINT NOT NULL,DESCRIPTION VARCHAR(32),GROUP_TYPE INTEGER NOT NULL, PRIMARY KEY(NAME));
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 SMALLINT NOT NULL,PERMISSIONS INTEGER NOT NULL, 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 SMALLINT NOT NULL,TASKNAME VARCHAR(128),ISMISSED SMALLINT 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,DESCRIPTION VARCHAR(255),TRIGGER_TYPE SMALLINT NOT NULL,TRIGGER_STATE SMALLINT NOT NULL,PREV_FIRE_TIME BIGINT,NEXT_FIRE_TIME BIGINT, PRIMARY KEY(TRIGGER_NAME));
CREATE TABLE SCHDLASTEXETIME_1 (TASKID VARCHAR(40) NOT NULL,LASTEXETIME BIGINT NOT NULL);
CREATE TABLE ACLS_WITH_RESOURCE_1 (ID INTEGER NOT NULL,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, PRIMARY KEY(ID));


--=================================================================
--  Init Data
--=================================================================
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);