/*
 * Copyright (c) 1998, Jinfonet Software, Inc.  All rights reserved. 
 */
 
 
/*==============================================================*/
/* DBMS name:      Interbase 7.5                                */
/* Created on:     2007-1-25 15:46:32                           */
/*==============================================================*/

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 TASKCONTEXT;

drop table DYNAMICNODE_2;

/* Table: ACLENTRIES_2 */
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"	          BOOLEAN            NOT NULL,
  "PERMISSIONS"	          INTEGER            NOT NULL,
 PRIMARY KEY ("ENTRY_ID")
);

/* Table: ACLS_2, Owner: SYSDBA */
CREATE TABLE "ACLS_2" 
(
  "ID"	                  INTEGER            NOT NULL,
  "NAME"	                VARCHAR(64)        NOT NULL,
  "CREATE_NAME"	          VARCHAR(32)        NOT NULL,
  "CREATE_TIME"	          NUMERIC(18, 0),
 PRIMARY KEY ("ID")
);

/* Table: ACLS_WITH_RESOURCE_1, Owner: SYSDBA */
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"	          NUMERIC(18, 0),
 PRIMARY KEY ("ID")
);

/* Table: ALIASES_1, Owner: SYSDBA */
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"	              BOOLEAN            NOT NULL,
 UNIQUE ("ID")
);

/* Table: CATALOGVERSION_2, Owner: SYSDBA */
CREATE TABLE "CATALOGVERSION_2" 
(
  "VERSIONNUMBER"	        INTEGER            NOT NULL,
  "VERSIONNAME"	          VARCHAR(128),     
  "RESOURCEID"	          INTEGER            NOT NULL,
  "CREATOR"	              VARCHAR(128),      
  "CREATEDTIME"	          NUMERIC(18, 0)     NOT NULL,
  "MODIFIER"	            VARCHAR(128),      
  "MODIFIEDTIME"	        NUMERIC(18, 0)     NOT NULL,
  "CATALOGFILE"	          VARCHAR(128)       NOT NULL,
  "ID"	                  NUMERIC(18, 0)     NOT NULL,
  UNIQUE ("ID")
);

/* Table: COMPLETEDPUBLISHTABLE_2, Owner: SYSDBA */
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
);

/* Table: COMPLETEDRESULTTABLE_3, Owner: SYSDBA */
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
);

/* Table: COMPLETEDTABLE_4, Owner: SYSDBA */
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"	        NUMERIC(18, 0),
  "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)
);

/* Table: DRESULT_2, Owner: SYSDBA */
CREATE TABLE "DRESULT_2" 
(
  "REPORTSET"	            VARCHAR(128),
  "VERSIONNUMBER"	        NUMERIC(18, 0)     NOT NULL,
  "REPORT"	              VARCHAR(128)       NOT NULL,
  "REPORTDISPLAYNAME"	    VARCHAR(128),      
  "RESULT"	              VARCHAR(128)       NOT NULL,
  "VIEWEDFORMATS"	        NUMERIC(18, 0),
  "PLSRESULTFMTS"	        NUMERIC(18, 0),
  "SECCONSTRAINTFMTS"       NUMERIC(18, 0)
);

/* Table: DYNAMICNODE_2, Owner: SYSDBA */
CREATE TABLE "DYNAMICNODE_2" 
(
  "NAME"	                VARCHAR(128)       NOT NULL,
  "ROOT"	                VARCHAR(128)       NOT NULL,
  "REALPATH"	            VARCHAR(256)       NOT NULL,
  "NODETYPE"	            SMALLINT           NOT NULL,
  "ENABLEARCHIVEPOLICY"	  BOOLEAN            NOT NULL,
  "DELETED"	              BOOLEAN            NOT NULL,
  "ACLID"	                INTEGER,
  "DESCRIPTION"	          VARCHAR(256),
  "MAXVERSIONAMOUNT"	    INTEGER,
   "ENABLELINKEDCAT"       BOOLEAN, 
  "LINKEDCAT"             VARCHAR(256), 
  "USEINHERITED"          BOOLEAN
);

/* Table: DYNAMICRESULT_1, Owner: SYSDBA */
CREATE TABLE "DYNAMICRESULT_1" 
(
  "ID"	                  INTEGER            NOT NULL,
  "REPORTNAME"	          VARCHAR(128)       NOT NULL,
  "VERSIONNUMBER"	        INTEGER            NOT NULL,
  "CREATOR"	              VARCHAR(128)       NOT NULL,
  "CREATEDTIME"	          NUMERIC(18, 0)     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"	          NUMERIC(18, 0)     NOT NULL,
  "LAUNCHTYPE"	          INTEGER            NOT NULL,
  "TASKID"	              VARCHAR(128),
  "EXPIRATIONTIME"	      NUMERIC(18, 0)     NOT NULL,
  "EXPIRE"	              BOOLEAN            NOT NULL,
  "EXPIRATIONMETHOD"	    INTEGER,
  "REPORTAMOUNT"	        INTEGER
);

/* Table: EXTENDACLENTRIES_2, Owner: SYSDBA */
CREATE TABLE "EXTENDACLENTRIES_2" 
(
  "PRINCIPAL_NAME"	      VARCHAR(64)        NOT NULL,
  "PRINCIPAL_TYPE"	      SMALLINT           NOT NULL,
  "PERMISSIONS"	          INTEGER            NOT NULL,
 UNIQUE ("PRINCIPAL_NAME", "PRINCIPAL_TYPE")
);

/* Table: FOLDERS_3, Owner: SYSDBA */
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
);

/* Table: GROUPPROFILES_1, Owner: SYSDBA */
CREATE TABLE "GROUPPROFILES_1" 
(
  "GROUP_NAME"	          VARCHAR(32),
  "SUB_GROUP_NAME"	      VARCHAR(32)
);

/* Table: GROUPS_1, Owner: SYSDBA */
CREATE TABLE "GROUPS_1" 
(
  "NAME"	                VARCHAR(32)        NOT NULL,
  "BUILDIN"	              BOOLEAN            NOT NULL,
  "DESCRIPTION"	          VARCHAR(32),       
  "GROUP_TYPE"	          INTEGER            NOT NULL,
  PRIMARY KEY ("NAME")
);

/* Table: GUPROFILES_1, Owner: SYSDBA */
CREATE TABLE "GUPROFILES_1" 
(
  "GROUP_NAME"	          VARCHAR(32),
  "USER_NAME"	            VARCHAR(32)
);

/* Table: NODES_3, Owner: SYSDBA */
CREATE TABLE "NODES_3" 
(
  "ID"	                  INTEGER            NOT NULL,
  "NAME"	                VARCHAR(64)        NOT NULL,
  "CREATORNAME"	          VARCHAR(32)        NOT NULL,
  "CREATETIME"	          NUMERIC(18, 0)     NOT NULL,
  "PARENTID"	            INTEGER            NOT NULL,
  "NODETYPE"	            SMALLINT           NOT NULL,
  "ACLID"	                INTEGER,
  "DESCRIPTION"	          VARCHAR(256), 
  "ENABLELINKEDCAT"       BOOLEAN, 
  "LINKEDCAT"             VARCHAR(256), 
  "USEINHERITED"          BOOLEAN
);

/* Table: REPORTVERSION_2, Owner: SYSDBA */
CREATE TABLE "REPORTVERSION_2" 
(
  "VERSIONNUMBER"	        INTEGER            NOT NULL,
  "VERSIONNAME"	          VARCHAR(128),
  "RESOURCEID"	          INTEGER            NOT NULL,
  "CREATOR"	              VARCHAR(128),
  "CREATETIME"	          NUMERIC(18, 0)     NOT NULL,
  "MODIFIER"	            VARCHAR(128),
  "MODIFIEDTIME"	        NUMERIC(18, 0)     NOT NULL,
  "REPORTFILE"	          VARCHAR(128)       NOT NULL,
  "ID"	                  NUMERIC(18, 0)     NOT NULL,
 UNIQUE ("RESOURCEID", "ID")
);

/* Table: RESOURCEMAP_1, Owner: SYSDBA */
CREATE TABLE "RESOURCEMAP_1" 
(
  "RESOURCEID"	          INTEGER            NOT NULL,
  "RESOURCENAME"	        VARCHAR(128)       NOT NULL,
  "RESOURCETYPE"	        SMALLINT           NOT NULL
);

/* Table: RESOURCENODES_3, Owner: SYSDBA */
CREATE TABLE "RESOURCENODES_3" 
(
  "ID"	                  INTEGER            NOT NULL,
  "RESOURCETYPE"	        SMALLINT           NOT NULL,
  "REALPATH"	            VARCHAR(256),
  "MAXVERSIONAMOUNT"	    INTEGER            NOT NULL,
  "ARCHIVENEWVERSION"	    BOOLEAN            NOT NULL,
  "ENABLEARCHIVEPOLICY"	  BOOLEAN            NOT NULL,
  "PROFILENAME"	            VARCHAR(256)
);

/* Table: RESULTVERSION_2, Owner: SYSDBA */
CREATE TABLE "RESULTVERSION_2" 
(
  "ID"	                  NUMERIC(18, 0)     NOT NULL,
  "VERSIONNUMBER"	        INTEGER            NOT NULL,
  "VERSIONNAME"	          VARCHAR(128)       NOT NULL,
  "RESOURCEID"	          INTEGER            NOT NULL,
  "CREATOR"	              VARCHAR(128),      
  "CREATEDTIME"	          NUMERIC(18, 0)     NOT NULL,
  "MODIFIER"	            VARCHAR(128),
  "MODIFIEDTIME"	        NUMERIC(18, 0)     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"	          NUMERIC(18, 0)     NOT NULL,
  "LAUNCHTYPE"	          INTEGER            NOT NULL,
  "TASKID"	              VARCHAR(128),
  "EXPIRATIONTIME"	      NUMERIC(18, 0)     NOT NULL,
  "EXPIRE"	              BOOLEAN            NOT NULL,
  "EXPIREATIONMETHOD"	    INTEGER,
  "SPECIFIEDFOLDER"	      VARCHAR(128),
  "REPORTAMOUNT"	        INTEGER,
 UNIQUE ("ID", "RESOURCEID")
);

/* Table: RESULT_2, Owner: SYSDBA */
CREATE TABLE "RESULT_2" 
(
  "RESOURCEID"	          NUMERIC(18, 0)     NOT NULL,
  "VERSIONNUMBER"	        NUMERIC(18, 0)     NOT NULL,
  "REPORT"	              VARCHAR(128)       NOT NULL,
  "REPORTDISPLAYNAME"	    VARCHAR(128),      
  "RESULT"	              VARCHAR(128)       NOT NULL,
  "VIEWEDFORMATS"	        NUMERIC(18, 0),
  "PLSRESULTFMTS"	        NUMERIC(18, 0),
  "SECCONSTRAINTFMTS"       NUMERIC(18, 0)
);

/* Table: RGPROFILES_1, Owner: SYSDBA */
CREATE TABLE "RGPROFILES_1" 
(
  "ROLE_NAME"	            VARCHAR(32),
  "GROUP_NAME"	          VARCHAR(32)
);

/* Table: ROLEPROFILES_2, Owner: SYSDBA */
CREATE TABLE "ROLEPROFILES_2" 
(
  "ROLE_NAME"	            VARCHAR(32),
  "SUB_ROLE_NAME"	        VARCHAR(32)
);

/* Table: ROLES_2, Owner: SYSDBA */
CREATE TABLE "ROLES_2" 
(
  "NAME"	                VARCHAR(32)        NOT NULL,
  "BUILDIN"	              BOOLEAN            NOT NULL,
  "DESCRIPTION"	          VARCHAR(32),       
  "ROLE_TYPE"	            INTEGER            NOT NULL,
 PRIMARY KEY ("NAME")
);

/* Table: SCHDLASTEXETIME_1, Owner: SYSDBA */
CREATE TABLE "SCHDLASTEXETIME_1" 
(
  "TASKID"	              VARCHAR(40)        NOT NULL,
  "LASTEXETIME"	          NUMERIC(18, 0)     NOT NULL
);

/* Table: TBL_IDGENRATOR_JINFONET, Owner: SYSDBA */
CREATE TABLE "TBL_IDGENRATOR_JINFONET" 
(
  "TF_NAME"	              VARCHAR(64)        NOT NULL,
  "NEXT_ID"	              INTEGER            NOT NULL,
 PRIMARY KEY ("TF_NAME")
);

/* Table: TRIGGERS_1, Owner: SYSDBA */
CREATE TABLE "TRIGGERS_1" 
(
  "TRIGGER_NAME"	        VARCHAR(80)        NOT NULL,
  "DESCRIPTION"	          VARCHAR(255),      
  "TRIGGER_TYPE"	        SMALLINT           NOT NULL,
  "TRIGGER_STATE"	        BOOLEAN            NOT NULL,
  "PREV_FIRE_TIME"	      NUMERIC(18, 0),
  "NEXT_FIRE_TIME"	      NUMERIC(18, 0),
 PRIMARY KEY ("TRIGGER_NAME")
);

/* Table: UPDATEDETAILS_1, Owner: SYSDBA */
CREATE TABLE "UPDATEDETAILS_1" 
(
  "UPDATE_ITEM"	          VARCHAR(32)        NOT NULL,
  "UPDATE_STATE"	        BOOLEAN            NOT NULL,
 PRIMARY KEY ("UPDATE_ITEM")
);

/* Table: USERPROFILES_2, Owner: SYSDBA */
CREATE TABLE "USERPROFILES_2" 
(
  "USER_NAME"	            VARCHAR(32),
  "ROLE_NAME"	            VARCHAR(32)
);

/* Table: USERS_3, Owner: SYSDBA */
CREATE TABLE "USERS_3" 
(
  "NAME"	                VARCHAR(32)        NOT NULL,
  "FULL_NAME"	            VARCHAR(128),
  "DESCRIPTION"	          VARCHAR(128),
  "EMAIL"	                VARCHAR(128),
  "CREATE_TIME"	          NUMERIC(18, 0)     NOT NULL,
  "USER_PSWD"  	          VARCHAR(128),
  "BUILDIN"	              BOOLEAN            NOT NULL,
  "ENABLE"	              BOOLEAN            NOT NULL,
  "MIN_PS_LENGTH"	        INTEGER,
  "LAST_MODIFY_TIME"	    NUMERIC(18, 0),
  "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,
 PRIMARY KEY ("NAME")
);

/* Table: VERSIONNODES_2, Owner: SYSDBA */
CREATE TABLE "VERSIONNODES_2" 
(
  "ID"	                  INTEGER            NOT NULL,
  "RESOURCEID"	          INTEGER            NOT NULL,
  "VERSIONNUMBER"	        INTEGER            NOT NULL,
  "EXPIRATIONTIME"	      NUMERIC(18, 0)     NOT NULL
);

/* Table: TASKCONTEXT, Owner: SYSDBA */
CREATE TABLE "TASKCONTEXT" 
(
  "ID"	                  INTEGER            NOT NULL,
  "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"	        NUMERIC(18, 0),
  "TC_TSK_WAITED"	        NUMERIC(18, 0),
  "TC_ENG_TOTAL"	        NUMERIC(18, 0),
  "TC_ENG_LOAD"         	NUMERIC(18, 0),
  "TC_ENG_EXPORT"	        NUMERIC(18, 0),
  "TC_ENG_OTHER"	        NUMERIC(18, 0),
  "TC_TSK_OTHER"	        NUMERIC(18, 0),
  "NC_RPT_PAGES"	        NUMERIC(18, 0),
  "NC_RPT_FORMATS"	      NUMERIC(18, 0),
  "NC_ENG_CONCURRENT"	    NUMERIC(18, 0),
  "NC_QUE_LENGTH"	        NUMERIC(18, 0),
 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);
