CREATE TABLE APP_ACT_COE_PAL_UPFILE(ID  CHAR(36) NOT NULL ,PALREPOSITORYID  CHAR(36),SHAPEID  NVARCHAR(64),FILETYPE  CHAR(1),FILENAME  NVARCHAR(128),DOWNLOAD  SMALLINT ,CREATEUSER  NVARCHAR(36),CREATETIME  DATETIME ,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),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),ISDEFAULT  SMALLINT ,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  SMALLINT ,RESOURCEID  NVARCHAR(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  NVARCHAR(36),ACTIONTYPE  NVARCHAR(64),EXTENDAPPS  NVARCHAR(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  NVARCHAR(36),CATEGORY  NVARCHAR(64),GROUPNAME  NVARCHAR(128),GROUPDESC  NVARCHAR(255),CREATEUSER  NVARCHAR(36),CREATEDATE  DATETIME ,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  SMALLINT ,RESOURCEID  NVARCHAR(128),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),ROLEID  NVARCHAR(36),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),STREAMID  CHAR(36),WSID  CHAR(36),TARGETTYPE  SMALLINT ,TARGETID  CHAR(36),TEAMID  CHAR(36),USERID  NVARCHAR(36),USERCOMMENT  NVARCHAR(1000),COMMENTDATE  DATETIME ,INFOTYPE  SMALLINT ,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),WSID  CHAR(36),USERID  NVARCHAR(36),AUDITORID  NVARCHAR(36),PUBLISHDATE  DATETIME ,PUBLISHDESC  NVARCHAR(1000),PUBLISHN  NUMERIC(6),PUBLISHC  NUMERIC(6),PUBLISHS  NUMERIC(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  NVARCHAR(255),TASKID  CHAR(36),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),WSID  CHAR(36),PROFILEID  NVARCHAR(36),TASKNAME  NVARCHAR(64),USERID  NVARCHAR(36),CREATETIME  DATETIME ,BEGINTIME  DATETIME ,ENDTIME  DATETIME ,TASKSTATE  SMALLINT ,THREADID  NVARCHAR(128),LANG  NVARCHAR(32),ISDISPLAY  VARCHAR(2),CONSTRAINT APP_ACT_COE_PAL_OUTPUT_TASK_PK PRIMARY KEY (ID)) ;

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

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

CREATE TABLE APP_ACT_COE_PAL_WORKSPACE(ID  CHAR(36) NOT NULL ,WSNAME  NVARCHAR(255),WSDM  NVARCHAR(255),WSADMIN  NVARCHAR(255),WSDESC  NVARCHAR(255),WSSTATE  SMALLINT ,WSORGTYPE  SMALLINT ,WSTCTYPE  SMALLINT ,WSBGURL  NVARCHAR(255),WSORDERINDEX  SMALLINT ,WSVER  SMALLINT ,WSVERSIONUUID  CHAR(36),ISUSE  SMALLINT ,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  NVARCHAR(36),PLNAME  NVARCHAR(128),PLLEVEL  SMALLINT ,PLPARENTID  NVARCHAR(36),PLORDERINDEX  SMALLINT ,PLISBOTTOMLEVEL  SMALLINT ,PLDESC  NVARCHAR(2000),PLRD  NVARCHAR(36),PLRP  NVARCHAR(36),PM  NVARCHAR(36),PLINPUT  NVARCHAR(255),PLOUTPUT  NVARCHAR(255),PLEXECTYPE  SMALLINT ,PLSYSTEMNAME  NVARCHAR(36),PLAWSPID  CHAR(36),PLDIAGRAMURL  NVARCHAR(255),PLCOLOR  NVARCHAR(36),PLCATEGORY  NVARCHAR(36),PLMETHODID  NVARCHAR(36),PLVER  SMALLINT ,PLVERSIONID  CHAR(36),ISUSE  SMALLINT ,ISPUBLISH  SMALLINT ,ISSYSTEMFILE  SMALLINT ,FILEPATH  NVARCHAR(255),HISTORYMAXVERSION  NUMERIC(6),VIEWCOUNT  NUMERIC(12),CREATEUSER  VARCHAR(36),MODIFYUSER  VARCHAR(36),CREATEDATE  DATETIME ,MODIFYDATE  DATETIME ,PLDUTYDEPT  NVARCHAR(36),PLDUTYPERSON  NVARCHAR(128),LOCKUSER  NVARCHAR(225),PUBLISHDATE  DATETIME ,CHANGEDATE  DATETIME ,STOPDATE  DATETIME ,ISSTOP  SMALLINT ,ISAPPROVAL  SMALLINT ,EXT1  NVARCHAR(64),EXT2  NVARCHAR(128),EXT3  NVARCHAR(255),EXT4  NVARCHAR(255),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),SHAPENAME  NVARCHAR(128),SHAPECATEGORYNAME  NVARCHAR(64),PALREPOSITORYID  CHAR(36),ISDELETE  CHAR(1),SHAPETYPE  NVARCHAR(36),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),SHAPENAME  NVARCHAR(128),SHAPECATEGORYNAME  NVARCHAR(64),PALREPOSITORYID  CHAR(36),ISDELETE  CHAR(1),SHAPETYPE  NVARCHAR(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  NVARCHAR(64),SHAPEID  NVARCHAR(64),SHAPETEXT  NVARCHAR(128),ATTRID  NVARCHAR(64),RELATIONFILEID  NVARCHAR(64),RELATIONSHAPEID  NVARCHAR(64),RELATIONSHAPETEXT  NVARCHAR(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  NVARCHAR(36),PLNAME  NVARCHAR(128),PLLEVEL  SMALLINT ,PLPARENTID  NVARCHAR(36),PLORDERINDEX  SMALLINT ,PLISBOTTOMLEVEL  SMALLINT ,PLDESC  NVARCHAR(2000),PLRD  NVARCHAR(36),PLRP  NVARCHAR(36),PM  NVARCHAR(36),PLINPUT  NVARCHAR(255),PLOUTPUT  NVARCHAR(255),PLEXECTYPE  SMALLINT ,PLSYSTEMNAME  NVARCHAR(36),PLAWSPID  CHAR(36),PLDIAGRAMURL  NVARCHAR(255),PLCOLOR  NVARCHAR(36),PLCATEGORY  NVARCHAR(36),PLMETHODID  NVARCHAR(36),PLVER  SMALLINT ,PLVERSIONID  CHAR(36),ISUSE  SMALLINT ,ISPUBLISH  SMALLINT ,ISSYSTEMFILE  SMALLINT ,FILEPATH  NVARCHAR(255),HISTORYMAXVERSION  NUMERIC(6),VIEWCOUNT  NUMERIC(12),CREATEUSER  VARCHAR(36),MODIFYUSER  VARCHAR(36),CREATEDATE  DATETIME ,MODIFYDATE  DATETIME ,PLDUTYDEPT  NVARCHAR(36),PLDUTYPERSON  NVARCHAR(128),ISSTOP  SMALLINT ,ISAPPROVAL  SMALLINT ,EXT1  NVARCHAR(64),EXT2  NVARCHAR(128),EXT3  NVARCHAR(255),EXT4  NVARCHAR(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  NVARCHAR(36),REMOVETIME  DATETIME ,WSID  NVARCHAR(36),RESOURCEID  NVARCHAR(36),REMOVETYPE  SMALLINT ,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  DATETIME ,USERID  NVARCHAR(36),REMARK  NVARCHAR(255),STATE  SMALLINT ,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  NVARCHAR(100),PROPERTYNAME  NVARCHAR(100),PROPERTYVALUE  NVARCHAR(2000),ORDERINDEX  SMALLINT ,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  NVARCHAR(36),SHAPEID  NVARCHAR(100),ATTRIBUTE  NVARCHAR(255),ORDERINDEX  SMALLINT ,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),ATTRID  NVARCHAR(100),ATTRNAME  NVARCHAR(100),ATTRVALUE  NVARCHAR(2000),CATEGORY  NVARCHAR(36),METHODID  NVARCHAR(36),TYPE  NVARCHAR(36),ISDELETE  NVARCHAR(10),ORDERINDEX  SMALLINT ,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  NVARCHAR(100),ATTRNAME  NVARCHAR(100),ATTRVALUE  NVARCHAR(2000),CATEGORY  NVARCHAR(36),METHODID  NVARCHAR(36),TYPE  NVARCHAR(36),SHAPENAME  NVARCHAR(64),ORDERINDEX  SMALLINT ,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),PLID  CHAR(36),TYPE  CHAR(100),VALUETEXT  NVARCHAR(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  NVARCHAR(36),CORRELATETYPE  SMALLINT ,ISCORRELATE  SMALLINT ,EXT1  NVARCHAR(64),EXT2  NVARCHAR(128),EXT3  NVARCHAR(255),EXT4  NVARCHAR(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  NUMERIC(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  NUMERIC(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);