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

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

CREATE TABLE APP_ACT_COE_PAL_SYSTEMNAME(ID  CHAR(36) NOT NULL ,SYSTEMNAME  NVARCHAR(36) NULL ,ISDEFAULT  SMALLINT  NULL ,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) NULL ,WSID  CHAR(36) NULL ,PERMTYPE  SMALLINT  NULL ,RESOURCEID  NVARCHAR(128) NULL ,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) NULL ,USERID  NVARCHAR(36) NULL ,ACTIONTYPE  NVARCHAR(64) NULL ,EXTENDAPPS  NVARCHAR(225) NULL ,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) NULL ,GROUPCODE  NVARCHAR(36) NULL ,CATEGORY  NVARCHAR(64) NULL ,GROUPNAME  NVARCHAR(128) NULL ,GROUPDESC  NVARCHAR(255) NULL ,CREATEUSER  NVARCHAR(36) NULL ,CREATEDATE  DATETIME  NULL ,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) NULL ,PERMTYPE  SMALLINT  NULL ,RESOURCEID  NVARCHAR(128) NULL ,CONSTRAINT APP_ACT_COE_PAL_USERGROUP_PERM_PK PRIMARY KEY (ID)) ;

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

CREATE TABLE APP_ACT_COE_PAL_COMMENT(ID  CHAR(36) NOT NULL ,PID  CHAR(36) NULL ,STREAMID  CHAR(36) NULL ,WSID  CHAR(36) NULL ,TARGETTYPE  SMALLINT  NULL ,TARGETID  CHAR(36) NULL ,TEAMID  CHAR(36) NULL ,USERID  NVARCHAR(36) NULL ,USERCOMMENT  NVARCHAR(1000) NULL ,COMMENTDATE  DATETIME  NULL ,INFOTYPE  SMALLINT  NULL ,CONSTRAINT APP_ACT_COE_PAL_COMMENT_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_PUBLISH(ID  CHAR(36) NOT NULL ,PROCESSINSTID  NVARCHAR(36) NULL ,WSID  CHAR(36) NULL ,USERID  NVARCHAR(36) NULL ,AUDITORID  NVARCHAR(36) NULL ,PUBLISHDATE  DATETIME  NULL ,PUBLISHDESC  NVARCHAR(1000) NULL ,PUBLISHN  NUMERIC(6) NULL ,PUBLISHC  NUMERIC(6) NULL ,PUBLISHS  NUMERIC(6) NULL ,TEAMID  CHAR(36) NULL ,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) NULL ,PALREPOSITORYID  CHAR(36) NULL ,ACTIONTYPE  CHAR(1) NULL ,PUBLISHDESC  NVARCHAR(255) NULL ,TASKID  CHAR(36) NULL ,CONSTRAINT APP_ACT_COE_PAL_PUBLISH_LIST_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_OUTPUT_TASK(ID  CHAR(36) NOT NULL ,TEAMID  CHAR(36) NULL ,WSID  CHAR(36) NULL ,PROFILEID  NVARCHAR(36) NULL ,TASKNAME  NVARCHAR(64) NULL ,USERID  NVARCHAR(36) NULL ,CREATETIME  DATETIME  NULL ,BEGINTIME  DATETIME  NULL ,ENDTIME  DATETIME  NULL ,TASKSTATE  SMALLINT  NULL ,THREADID  NVARCHAR(128) NULL ,LANG  NVARCHAR(32) NULL ,ISDISPLAY  VARCHAR(2) NULL ,CONSTRAINT APP_ACT_COE_PAL_OUTPUT_TASK_PK PRIMARY KEY (ID)) ;

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

CREATE TABLE APP_ACT_COE_USER(ID  CHAR(36) NOT NULL ,USERID  NVARCHAR(36) NULL ,ISADMIN  SMALLINT  NULL ,CONSTRAINT APP_ACT_COE_USER_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_WORKSPACE(ID  CHAR(36) NOT NULL ,WSNAME  NVARCHAR(255) NULL ,WSDM  NVARCHAR(255) NULL ,WSADMIN  NVARCHAR(255) NULL ,WSDESC  NVARCHAR(255) NULL ,WSSTATE  SMALLINT  NULL ,WSORGTYPE  SMALLINT  NULL ,WSTCTYPE  SMALLINT  NULL ,WSBGURL  NVARCHAR(255) NULL ,WSORDERINDEX  SMALLINT  NULL ,WSVER  SMALLINT  NULL ,WSVERSIONUUID  CHAR(36) NULL ,ISUSE  SMALLINT  NULL ,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) NULL ,PLRID  CHAR(36) NULL ,PLNO  NVARCHAR(36) NULL ,PLNAME  NVARCHAR(128) NULL ,PLLEVEL  SMALLINT  NULL ,PLPARENTID  NVARCHAR(36) NULL ,PLORDERINDEX  SMALLINT  NULL ,PLISBOTTOMLEVEL  SMALLINT  NULL ,PLDESC  NVARCHAR(2000) NULL ,PLRD  NVARCHAR(36) NULL ,PLRP  NVARCHAR(36) NULL ,PM  NVARCHAR(36) NULL ,PLINPUT  NVARCHAR(255) NULL ,PLOUTPUT  NVARCHAR(255) NULL ,PLEXECTYPE  SMALLINT  NULL ,PLSYSTEMNAME  NVARCHAR(36) NULL ,PLAWSPID  CHAR(36) NULL ,PLDIAGRAMURL  NVARCHAR(255) NULL ,PLCOLOR  NVARCHAR(36) NULL ,PLCATEGORY  NVARCHAR(36) NULL ,PLMETHODID  NVARCHAR(36) NULL ,PLVER  SMALLINT  NULL ,PLVERSIONID  CHAR(36) NULL ,ISUSE  SMALLINT  NULL ,ISPUBLISH  SMALLINT  NULL ,ISSYSTEMFILE  SMALLINT  NULL ,FILEPATH  NVARCHAR(255) NULL ,HISTORYMAXVERSION  NUMERIC(6) NULL ,VIEWCOUNT  NUMERIC(12) NULL ,CREATEUSER  VARCHAR(36) NULL ,MODIFYUSER  VARCHAR(36) NULL ,CREATEDATE  DATETIME  NULL ,MODIFYDATE  DATETIME  NULL ,PLDUTYDEPT  NVARCHAR(36) NULL ,PLDUTYPERSON  NVARCHAR(128) NULL ,LOCKUSER  NVARCHAR(225) NULL ,PUBLISHDATE  DATETIME  NULL ,CHANGEDATE  DATETIME  NULL ,STOPDATE  DATETIME  NULL ,ISSTOP  SMALLINT  NULL ,ISAPPROVAL  SMALLINT  NULL ,EXT1  NVARCHAR(64) NULL ,EXT2  NVARCHAR(128) NULL ,EXT3  NVARCHAR(255) NULL ,EXT4  NVARCHAR(255) NULL ,CONSTRAINT APP_ACT_COE_PAL_REPOSITORY_PK PRIMARY KEY (ID)) ;

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

CREATE TABLE APP_ACT_COE_PAL_SHAPE_PASTE(ID  NVARCHAR(64) NOT NULL ,SHAPEGROUPTID  NVARCHAR(64) NULL ,SHAPENAME  NVARCHAR(128) NULL ,SHAPECATEGORYNAME  NVARCHAR(64) NULL ,PALREPOSITORYID  CHAR(36) NULL ,ISDELETE  CHAR(1) NULL ,SHAPETYPE  NVARCHAR(36) NULL ,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  NVARCHAR(64) NULL ,SHAPEID  NVARCHAR(64) NULL ,SHAPETEXT  NVARCHAR(128) NULL ,ATTRID  NVARCHAR(64) NULL ,RELATIONFILEID  NVARCHAR(64) NULL ,RELATIONSHAPEID  NVARCHAR(64) NULL ,RELATIONSHAPETEXT  NVARCHAR(128) NULL ,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) NULL ,WSID  CHAR(36) NULL ,PLRID  CHAR(36) NULL ,PLNO  NVARCHAR(36) NULL ,PLNAME  NVARCHAR(128) NULL ,PLLEVEL  SMALLINT  NULL ,PLPARENTID  NVARCHAR(36) NULL ,PLORDERINDEX  SMALLINT  NULL ,PLISBOTTOMLEVEL  SMALLINT  NULL ,PLDESC  NVARCHAR(2000) NULL ,PLRD  NVARCHAR(36) NULL ,PLRP  NVARCHAR(36) NULL ,PM  NVARCHAR(36) NULL ,PLINPUT  NVARCHAR(255) NULL ,PLOUTPUT  NVARCHAR(255) NULL ,PLEXECTYPE  SMALLINT  NULL ,PLSYSTEMNAME  NVARCHAR(36) NULL ,PLAWSPID  CHAR(36) NULL ,PLDIAGRAMURL  NVARCHAR(255) NULL ,PLCOLOR  NVARCHAR(36) NULL ,PLCATEGORY  NVARCHAR(36) NULL ,PLMETHODID  NVARCHAR(36) NULL ,PLVER  SMALLINT  NULL ,PLVERSIONID  CHAR(36) NULL ,ISUSE  SMALLINT  NULL ,ISPUBLISH  SMALLINT  NULL ,ISSYSTEMFILE  SMALLINT  NULL ,FILEPATH  NVARCHAR(255) NULL ,HISTORYMAXVERSION  NUMERIC(6) NULL ,VIEWCOUNT  NUMERIC(12) NULL ,CREATEUSER  VARCHAR(36) NULL ,MODIFYUSER  VARCHAR(36) NULL ,CREATEDATE  DATETIME  NULL ,MODIFYDATE  DATETIME  NULL ,PLDUTYDEPT  NVARCHAR(36) NULL ,PLDUTYPERSON  NVARCHAR(128) NULL ,ISSTOP  SMALLINT  NULL ,ISAPPROVAL  SMALLINT  NULL ,EXT1  NVARCHAR(64) NULL ,EXT2  NVARCHAR(128) NULL ,EXT3  NVARCHAR(255) NULL ,EXT4  NVARCHAR(255) NULL ,CONSTRAINT AWS_PAL_REPOSITORY_R_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_REPO_R_INFO(ID  CHAR(36) NOT NULL ,REMOVEUSER  NVARCHAR(36) NULL ,REMOVETIME  DATETIME  NULL ,WSID  NVARCHAR(36) NULL ,RESOURCEID  NVARCHAR(36) NULL ,REMOVETYPE  SMALLINT  NULL ,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) NULL ,BACKUPTIME  DATETIME  NULL ,USERID  NVARCHAR(36) NULL ,REMARK  NVARCHAR(255) NULL ,STATE  SMALLINT  NULL ,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) NULL ,PROPERTYID  NVARCHAR(100) NULL ,PROPERTYNAME  NVARCHAR(100) NULL ,PROPERTYVALUE  NVARCHAR(2000) NULL ,ORDERINDEX  SMALLINT  NULL ,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) NULL ,METHODID  NVARCHAR(36) NULL ,SHAPEID  NVARCHAR(100) NULL ,ATTRIBUTE  NVARCHAR(255) NULL ,ORDERINDEX  SMALLINT  NULL ,CONSTRAINT APP_ACT_COE_PAL_SHAPE_CONFIG_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_ATTR(ID  CHAR(36) NOT NULL ,WSID  CHAR(36) NULL ,ATTRID  NVARCHAR(100) NULL ,ATTRNAME  NVARCHAR(100) NULL ,ATTRVALUE  NVARCHAR(2000) NULL ,CATEGORY  NVARCHAR(36) NULL ,METHODID  NVARCHAR(36) NULL ,TYPE  NVARCHAR(36) NULL ,ISDELETE  NVARCHAR(10) NULL ,ORDERINDEX  SMALLINT  NULL ,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) NULL ,ATTRID  NVARCHAR(100) NULL ,ATTRNAME  NVARCHAR(100) NULL ,ATTRVALUE  NVARCHAR(2000) NULL ,CATEGORY  NVARCHAR(36) NULL ,METHODID  NVARCHAR(36) NULL ,TYPE  NVARCHAR(36) NULL ,SHAPENAME  NVARCHAR(64) NULL ,ORDERINDEX  SMALLINT  NULL ,CONSTRAINT APP_ACT_COE_PAL_SHAPE_ATTRIBUTE_PK PRIMARY KEY (ID)) ;

CREATE TABLE APP_ACT_COE_PAL_SPCL_PROP(ID  CHAR(36) NOT NULL ,WSID  CHAR(36) NULL ,PLID  CHAR(36) NULL ,TYPE  CHAR(100) NULL ,VALUETEXT  NVARCHAR(2000) NULL ,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) NULL ,PLAWSVERSIONID  CHAR(36) NULL ,PLAWSID  CHAR(36) NULL ,PLVERSIONID  NVARCHAR(36) NULL ,CORRELATETYPE  SMALLINT  NULL ,ISCORRELATE  SMALLINT  NULL ,EXT1  NVARCHAR(64) NULL ,EXT2  NVARCHAR(128) NULL ,EXT3  NVARCHAR(255) NULL ,EXT4  NVARCHAR(255) NULL ,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) NULL ,PLVERSIONID  CHAR(36) NULL ,SORT  NUMERIC(16) NULL ,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) NULL ,RESOURCEID  CHAR(36) NULL ,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) NULL ,PLVERSIONID  CHAR(36) NULL ,COUNT  NUMERIC(16) NULL ,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);