CREATE TABLE APP_ACT_COE_PAL_UPFILE(ID  CHAR(36) NOT NULL ,PALREPOSITORYID  CHAR(36),SHAPEID  NVARCHAR2(64),FILETYPE  CHAR(1),FILENAME  NVARCHAR2(128),DOWNLOAD  NUMBER(1),CREATEUSER  NVARCHAR2(36),CREATETIME  DATE ,CONSTRAINT APP_ACT_COE_PAL_UPFILE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_FILE(ID  NVARCHAR2(64) NOT NULL ,PALREPOSITORYID  CHAR(36),CONSTRAINT APP_ACT_COE_PAL_SHAPE_FILE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SYSTEMNAME(ID  CHAR(36) NOT NULL ,SYSTEMNAME  NVARCHAR2(36),ISDEFAULT  NUMBER(1),CONSTRAINT APP_ACT_COE_PAL_SYSTEMNAME_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_TEAM_PERM(ID  CHAR(36) NOT NULL ,TEAMID  CHAR(36),WSID  CHAR(36),PERMTYPE  NUMBER(2),RESOURCEID  NVARCHAR2(128),CONSTRAINT APP_ACT_COE_TEAM_PERM_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_TEAMMBR_PERM(ID  CHAR(36) NOT NULL ,TEAMID  CHAR(36),USERID  NVARCHAR2(36),ACTIONTYPE  NVARCHAR2(64),EXTENDAPPS  NVARCHAR2(225),CONSTRAINT APP_ACT_COE_TEAMMEMBER_PERM_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_USERGRP(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),GROUPCODE  NVARCHAR2(36),CATEGORY  NVARCHAR2(64),GROUPNAME  NVARCHAR2(128),GROUPDESC  NVARCHAR2(255),CREATEUSER  NVARCHAR2(36),CREATEDATE  DATE ,CONSTRAINT APP_ACT_COE_PAL_USERGROUP_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_USERGRP_PERM(ID  CHAR(36) NOT NULL ,GROUPID  CHAR(36),PERMTYPE  NUMBER(2),RESOURCEID  NVARCHAR2(128),CONSTRAINT APP_ACT_COE_PAL_USERGROUP_P_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_USERGRP_ROLE(ID  CHAR(36) NOT NULL ,GROUPID  CHAR(36),ROLEID  NVARCHAR2(36),CONSTRAINT APP_ACT_COE_PAL_USERGROUP_R_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_COMMENT(ID  CHAR(36) NOT NULL ,PID  CHAR(36),STREAMID  CHAR(36),WSID  CHAR(36),TARGETTYPE  NUMBER(1),TARGETID  CHAR(36),TEAMID  CHAR(36),USERID  NVARCHAR2(36),USERCOMMENT  NVARCHAR2(1000),COMMENTDATE  DATE ,INFOTYPE  NUMBER(1),CONSTRAINT APP_ACT_COE_PAL_COMMENT_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_PUBLISH(ID  CHAR(36) NOT NULL ,PROCESSINSTID  NVARCHAR2(36),WSID  CHAR(36),USERID  NVARCHAR2(36),AUDITORID  NVARCHAR2(36),PUBLISHDATE  DATE ,PUBLISHDESC  NVARCHAR2(1000),PUBLISHN  NUMBER(6),PUBLISHC  NUMBER(6),PUBLISHS  NUMBER(6),TEAMID  CHAR(36),CONSTRAINT APP_ACT_COE_PAL_PUBLISH_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_PUBLISH_LIST(ID  CHAR(36) NOT NULL ,PID  CHAR(36),PALREPOSITORYID  CHAR(36),ACTIONTYPE  CHAR(1),PUBLISHDESC  NVARCHAR2(255),TASKID  CHAR(36),CONSTRAINT APP_ACT_COE_PAL_PUBLISH_L_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_OUTPUT_TASK(ID  CHAR(36) NOT NULL ,TEAMID  CHAR(36),WSID  CHAR(36),PROFILEID  NVARCHAR2(36),TASKNAME  NVARCHAR2(64),USERID  NVARCHAR2(36),CREATETIME  DATE ,BEGINTIME  DATE ,ENDTIME  DATE ,TASKSTATE  NUMBER(1),THREADID  NVARCHAR2(128),LANG  NVARCHAR2(32),ISDISPLAY  VARCHAR2(2),CONSTRAINT APP_ACT_COE_PAL_OUTPUT_TASK_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PROP(PROPERTYKEY  NVARCHAR2(128) NOT NULL ,PROPERTYVALUE  CLOB ,CONSTRAINT APP_ACT_COE_PROPERTY_PK PRIMARY KEY (PROPERTYKEY)) ;

CREATE TABLE APP_ACT_COE_USER(ID  CHAR(36) NOT NULL ,USERID  NVARCHAR2(36),ISADMIN  NUMBER(1),CONSTRAINT APP_ACT_COE_USER_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_WORKSPACE(ID  CHAR(36) NOT NULL ,WSNAME  NVARCHAR2(255),WSDM  NVARCHAR2(255),WSADMIN  NVARCHAR2(255),WSDESC  NVARCHAR2(255),WSSTATE  NUMBER(1),WSORGTYPE  NUMBER(1),WSTCTYPE  NUMBER(1),WSBGURL  NVARCHAR2(255),WSORDERINDEX  NUMBER(3),WSVER  NUMBER(3),WSVERSIONUUID  CHAR(36),ISUSE  NUMBER(1),CONSTRAINT APP_ACT_COE_PAL_WORKSPACE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_REPOSITORY(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),PLRID  CHAR(36),PLNO  NVARCHAR2(36),PLNAME  NVARCHAR2(128),PLLEVEL  NUMBER(2),PLPARENTID  NVARCHAR2(36),PLORDERINDEX  NUMBER(3),PLISBOTTOMLEVEL  NUMBER(1),PLDESC  NVARCHAR2(2000),PLRD  NVARCHAR2(36),PLRP  NVARCHAR2(36),PM  NVARCHAR2(36),PLINPUT  NVARCHAR2(255),PLOUTPUT  NVARCHAR2(255),PLEXECTYPE  NUMBER(1),PLSYSTEMNAME  NVARCHAR2(36),PLAWSPID  CHAR(36),PLDIAGRAMURL  NVARCHAR2(255),PLCOLOR  NVARCHAR2(36),PLCATEGORY  NVARCHAR2(36),PLMETHODID  NVARCHAR2(36),PLVER  NUMBER(3),PLVERSIONID  CHAR(36),ISUSE  NUMBER(1),ISPUBLISH  NUMBER(1),ISSYSTEMFILE  NUMBER(1),FILEPATH  NVARCHAR2(255),HISTORYMAXVERSION  NUMBER(6),VIEWCOUNT  NUMBER(12),CREATEUSER  VARCHAR2(36),MODIFYUSER  VARCHAR2(36),CREATEDATE  DATE ,MODIFYDATE  DATE ,PLDUTYDEPT  NVARCHAR2(36),PLDUTYPERSON  NVARCHAR2(128),LOCKUSER  NVARCHAR2(225),PUBLISHDATE  DATE ,CHANGEDATE  DATE ,STOPDATE  DATE ,ISSTOP  NUMBER(1),ISAPPROVAL  NUMBER(1),EXT1  NVARCHAR2(64),EXT2  NVARCHAR2(128),EXT3  NVARCHAR2(255),EXT4  NVARCHAR2(255),CONSTRAINT APP_ACT_COE_PAL_REPOSITORY_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_COPY(ID  NVARCHAR2(64) NOT NULL ,SHAPEGROUPTID  NVARCHAR2(64),SHAPENAME  NVARCHAR2(128),SHAPECATEGORYNAME  NVARCHAR2(64),PALREPOSITORYID  CHAR(36),ISDELETE  CHAR(1),SHAPETYPE  NVARCHAR2(36),CONSTRAINT APP_ACT_COE_PAL_SHAPE_COPY_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_PASTE(ID  NVARCHAR2(64) NOT NULL ,SHAPEGROUPTID  NVARCHAR2(64),SHAPENAME  NVARCHAR2(128),SHAPECATEGORYNAME  NVARCHAR2(64),PALREPOSITORYID  CHAR(36),ISDELETE  CHAR(1),SHAPETYPE  NVARCHAR2(36),CONSTRAINT APP_ACT_COE_PAL_SHAPE_PASTE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_RLAT(ID  CHAR(36) NOT NULL ,FILEID  NVARCHAR2(64),SHAPEID  NVARCHAR2(64),SHAPETEXT  NVARCHAR2(128),ATTRID  NVARCHAR2(64),RELATIONFILEID  NVARCHAR2(64),RELATIONSHAPEID  NVARCHAR2(64),RELATIONSHAPETEXT  NVARCHAR2(128),CONSTRAINT APP_ACT_COE_PAL_SHAPE_RT_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_REPO_R(ID  CHAR(36) NOT NULL ,REMOVEID  CHAR(36),WSID  CHAR(36),PLRID  CHAR(36),PLNO  NVARCHAR2(36),PLNAME  NVARCHAR2(128),PLLEVEL  NUMBER(2),PLPARENTID  NVARCHAR2(36),PLORDERINDEX  NUMBER(3),PLISBOTTOMLEVEL  NUMBER(1),PLDESC  NVARCHAR2(2000),PLRD  NVARCHAR2(36),PLRP  NVARCHAR2(36),PM  NVARCHAR2(36),PLINPUT  NVARCHAR2(255),PLOUTPUT  NVARCHAR2(255),PLEXECTYPE  NUMBER(1),PLSYSTEMNAME  NVARCHAR2(36),PLAWSPID  CHAR(36),PLDIAGRAMURL  NVARCHAR2(255),PLCOLOR  NVARCHAR2(36),PLCATEGORY  NVARCHAR2(36),PLMETHODID  NVARCHAR2(36),PLVER  NUMBER(3),PLVERSIONID  CHAR(36),ISUSE  NUMBER(1),ISPUBLISH  NUMBER(1),ISSYSTEMFILE  NUMBER(1),FILEPATH  NVARCHAR2(255),HISTORYMAXVERSION  NUMBER(6),VIEWCOUNT  NUMBER(12),CREATEUSER  VARCHAR2(36),MODIFYUSER  VARCHAR2(36),CREATEDATE  DATE ,MODIFYDATE  DATE ,PLDUTYDEPT  NVARCHAR2(36),PLDUTYPERSON  NVARCHAR2(128),ISSTOP  NUMBER(1),ISAPPROVAL  NUMBER(1),EXT1  NVARCHAR2(64),EXT2  NVARCHAR2(128),EXT3  NVARCHAR2(255),EXT4  NVARCHAR2(255),CONSTRAINT AWS_PAL_REPOSITORY_R_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_REPO_R_INFO(ID  CHAR(36) NOT NULL ,REMOVEUSER  NVARCHAR2(36),REMOVETIME  DATE ,WSID  NVARCHAR2(36),RESOURCEID  NVARCHAR2(36),REMOVETYPE  NUMBER(1),CONSTRAINT AWS_PAL_REPOSITORY_R_INFO_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_BACKUP(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),BACKUPTIME  DATE ,USERID  NVARCHAR2(36),REMARK  NVARCHAR2(255),STATE  NUMBER(1),CONSTRAINT APP_ACT_COE_PAL_BACKUP_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_PROP(ID  CHAR(36) NOT NULL ,PLID  CHAR(36),PROPERTYID  NVARCHAR2(100),PROPERTYNAME  NVARCHAR2(100),PROPERTYVALUE  NVARCHAR2(2000),ORDERINDEX  NUMBER(3),CONSTRAINT APP_ACT_COE_PAL_PROPERTY_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_CONFIG(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),METHODID  NVARCHAR2(36),SHAPEID  NVARCHAR2(100),ATTRIBUTE  NVARCHAR2(255),ORDERINDEX  NUMBER(3),CONSTRAINT APP_ACT_COE_PAL_SHAPE_C_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_ATTR(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),ATTRID  NVARCHAR2(100),ATTRNAME  NVARCHAR2(100),ATTRVALUE  NVARCHAR2(2000),CATEGORY  NVARCHAR2(36),METHODID  NVARCHAR2(36),TYPE  NVARCHAR2(36),ISDELETE  NVARCHAR2(10),ORDERINDEX  NUMBER(3),CONSTRAINT APP_ACT_COE_PAL_ATTRIBUTE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SHAPE_ATTR(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),ATTRID  NVARCHAR2(100),ATTRNAME  NVARCHAR2(100),ATTRVALUE  NVARCHAR2(2000),CATEGORY  NVARCHAR2(36),METHODID  NVARCHAR2(36),TYPE  NVARCHAR2(36),SHAPENAME  NVARCHAR2(64),ORDERINDEX  NUMBER(3),CONSTRAINT APP_ACT_COE_PAL_SHAPE_ATTR_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SPCL_PROP(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),PLID  CHAR(36),TYPE  CHAR(100),VALUETEXT  NVARCHAR2(2000),CONSTRAINT APP_ACT_COE_PAL_SPECIAL_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_CORRELATE(PLID  CHAR(36) NOT NULL ,WSID  CHAR(36),PLAWSVERSIONID  CHAR(36),PLAWSID  CHAR(36),PLVERSIONID  NVARCHAR2(36),CORRELATETYPE  NUMBER(1),ISCORRELATE  NUMBER(1),EXT1  NVARCHAR2(64),EXT2  NVARCHAR2(128),EXT3  NVARCHAR2(255),EXT4  NVARCHAR2(255),CONSTRAINT APP_ACT_COE_PAL_CORRELATE_PK PRIMARY KEY (PLID)) ;

CREATE TABLE APP_ACT_COE_PAL_PUBLISH_COM(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),PLVERSIONID  CHAR(36),SORT  NUMBER(16),CONSTRAINT APP_ACT_COE_PAL_COMMON_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_TEAMMBR_PERM_EXT(ID  CHAR(36) NOT NULL ,BINDID  CHAR(36),RESOURCEID  CHAR(36),CONSTRAINT APP_ACT_COE_PAL_EXTEND_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_PUBLISH_FREQ(ID  CHAR(36) NOT NULL ,WSID  CHAR(36),PLVERSIONID  CHAR(36),COUNT  NUMBER(16),CONSTRAINT APP_ACT_COE_PAL_FREQUENCY_PK PRIMARY KEY (ID)) ;

CREATE INDEX APP_ACT_COE_PAL_PUBLISH_IND1 ON  APP_ACT_COE_PAL_PUBLISH (PUBLISHDATE);
CREATE INDEX APP_ACT_COE_PAL_PUBLISH_L_I ON  APP_ACT_COE_PAL_PUBLISH_LIST (PID);
ALTER TABLE  APP_ACT_COE_PAL_USERGRP ADD CONSTRAINT APP_ACT_COE_PAL_USERGRP_UK UNIQUE (WSID,GROUPCODE);
ALTER TABLE  APP_ACT_COE_PAL_USERGRP_PERM ADD CONSTRAINT APP_ACT_COE_PAL_USERGRP_P_UK UNIQUE (GROUPID,PERMTYPE,RESOURCEID);
ALTER TABLE  APP_ACT_COE_PAL_USERGRP_ROLE ADD CONSTRAINT APP_ACT_COE_PAL_USERGRP_R_UK UNIQUE (GROUPID,ROLEID);
ALTER TABLE  APP_ACT_COE_TEAM_PERM ADD CONSTRAINT APP_ACT_COE_TEAM_PERM_UK UNIQUE (TEAMID,WSID,PERMTYPE,RESOURCEID);
ALTER TABLE  APP_ACT_COE_TEAMMBR_PERM ADD CONSTRAINT APP_ACT_COE_TEAMMBR_PERM_UK UNIQUE (TEAMID,USERID);
CREATE INDEX APP_ACT_COE_PAL_COMMENT_IND1 ON APP_ACT_COE_PAL_COMMENT (TARGETID,COMMENTDATE);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('e0583f9a-2f6e-49fe-b4e8-4b9a5f3c257a','AWS BPM',0);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('0df9d8b1-b082-4e3f-aadb-45fd76b82aeb','SAP ERP',0);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('cfbcec4a-b0ed-4e43-9866-bcda72d69eab','Oracle ERP',0);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('2a5faee5-0c12-4e29-b32e-aab42552ff6d','Oracle Siebel CRM',0);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('16f37ce8-dc62-4ffb-b6ca-fc248b51ff73','Oracle JDE ERP',0);

INSERT INTO APP_ACT_COE_PAL_SYSTEMNAME(ID,SYSTEMNAME,ISDEFAULT) VALUES('275e402a-a2c6-4d57-83a1-3f0da50539e4','Oracle PeopleSoft',0);

INSERT INTO APP_ACT_COE_PROP(PROPERTYKEY,PROPERTYVALUE) VALUES('CoE_Test','false');

INSERT INTO APP_ACT_COE_PROP(PROPERTYKEY,PROPERTYVALUE) VALUES('InitStep','6');

INSERT INTO APP_ACT_COE_USER(ID,USERID,ISADMIN) VALUES('9e23d27b-26a2-4ec5-839b-d9fe4c1eb9e3','admin',1);