Skip to content

Commit

Permalink
Maintain clean up scripts for Camuda BPM 7.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ingorichtsmeier committed Mar 20, 2017
1 parent 5b61a2d commit 7bf997c
Show file tree
Hide file tree
Showing 6 changed files with 493 additions and 71 deletions.
6 changes: 6 additions & 0 deletions snippets/clean-up-history/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ If you run

you will restore all process instances from archive run 8 to 10.

###Improvements Backlog

- Handle INDENITYLINK
- Handle Cases
- Find Batches even if no process instances were selected

27 changes: 23 additions & 4 deletions snippets/clean-up-history/oracle-scripts/DROP_CamundaArchiving.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Camunda Version: 7.3.2-ee; Oracle 12c tested
State as of: 23.02.2015
Camunda Version: 7.6.0; Oracle 12c tested
State as of: 20.03.2017
S. Hellmann, M. Krassmann: Silpion; T. Hirsch for Haspa; Ingo Richtsmeier for Camunda;
DOC.:
Expand All @@ -20,7 +20,11 @@ DROP TABLE TMP_ARCHIVING_PROCINST;
/*-- TMP_ARCHIVING_BYTEARRAY */
DROP TABLE TMP_ARCHIVING_BYTEARRAY;

/* drop own extentions columns:
DROP TABLE TMP_ARCHIVING_DEC;

DROP TABLE TMP_ARCHIVING_BATCH;

/* drop own extentions columns: */
alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
Expand All @@ -30,7 +34,12 @@ alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
*/
alter table ARCHIVE_ACT_HI_DECINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_DEC_IN DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_DEC_OUT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_BATCH DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
alter table ARCHIVE_ACT_HI_JOB_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS);
/**/

/*--#1 */
drop TABLE ARCHIVE_ACT_HI_PROCINST;
Expand All @@ -52,6 +61,16 @@ drop TABLE ARCHIVE_ACT_HI_OP_LOG;
drop TABLE ARCHIVE_ACT_HI_INCIDENT;
/*--#10 */
drop TABLE ARCHIVE_ACT_GE_BYTEARRAY;
/*--#11 */
drop TABLE ARCHIVE_ACT_HI_DECINST;
/*--#12 */
drop TABLE ARCHIVE_ACT_HI_DEC_IN;
/*--#13 */
drop TABLE ARCHIVE_ACT_HI_DEC_OUT;
/*--#14 */
drop TABLE ARCHIVE_ACT_HI_BATCH;
/*--#15 */
drop TABLE ARCHIVE_ACT_HI_JOB_LOG;

/* drop PL SQL functions: */
drop function ARCHIVE_CAMUNDA_HISTORY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,66 @@
/*
Camunda Version: 7.3.2-ee; Oracle 12c tested
State as of: 24.02.2015
S. Hellmann, M. Krassmann: Silpion; T. Hirsch for Haspa; Ingo Richtsmeier for Camunda;
-- +================================================================+
-- | STEP-1__CamundaArchiving_MODIFY_Indexes_History.sql
-- +================================================================+
-- | Camunda Version: 7.6.0; Oracle 12c tested
-- | State as of: 20.03.2017
-- | S. Hellmann, M. Krassmann: Silpion; T. Hirsch for Haspa; Ingo Richtsmeier for Camunda;
-- | Thomas Lenarz for Talanx;
-- |
-- | Changed: 25.08.2016
-- | added index of table SOAPMESSAGES for Talanx
-- | Thomas Lenarz for Talanx
-- |
-- | Changed: 06.12.2016
-- | Index INDEX IDX_ACT_HI_OP_LOG_PIID ist bereits in den Talanx-Umgebungen angelegt.
-- | Daher entsprechenden Create auskommentiert.
-- | Thomas Lenarz for Talanx
-- |
-- | DOC.:
-- | Add some Camunda Indexes to history schema part (for Archiving)
-- +================================================================+

DOC.:
--------------------------------------------------------------------------------------
Add some Camunda Indexes to history schema part (for Archiving)
*/
COLUMN vcomplogfile new_value vcomplogfile NOPRINT;
SELECT 'STEP-1__CamundaArchiving_MODIFY_Indexes_History_'|| TO_CHAR(SYSDATE,'DDMonYYYY_hh24_mi_ss') || '.lst' AS vcomplogfile
FROM dual;
spool &vcomplogfile

whenever sqlerror continue
whenever oserror continue
set autocommit off;
set heading off;
-- +================================================================+
show user;
select 'DATABASE = ' || sys_context('USERENV','DB_NAME') DB from dual;
-- +================================================================+
set heading on;
set echo on;
-- +================================================================+
-- +==== ENDE SQL HEADER ===========================================+
-- +================================================================+

WHENEVER SQLERROR EXIT SQL.SQLCODE;
SET SERVEROUTPUT ON;
-- Block 1 ohne Abbruch bei Fehler [z.B. drop Table....]

-- Block 2 Abbruch bei Fehler
whenever SQLERROR EXIT sql.sqlcode ROLLBACK
whenever OSERROR EXIT 20001 ROLLBACK

create INDEX IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_);
create INDEX IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_);
create INDEX IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_);
create INDEX IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_);
create INDEX IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_);
create INDEX IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_);
/*Already indexed in camunda-bpm-7.3.0 uncomment for other versions */
/* 06.12.2016: Thomas Lenarz, Folgender Index existiert schon
in den Talanx-Umgebungen. Muss also nicht mehr
angelegt werden.
create INDEX IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_);
*/
create INDEX IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_);

/*Already indexed in camunda-bpm-7.6.0 uncomment for other versions */
/*
create INDEX IDX_ACT_HI_DETAIL_PIID ON ACT_HI_DETAIL(PROC_INST_ID_);
create INDEX IDX_ACT_HI_VARINST_PIID ON ACT_HI_VARINST (PROC_INST_ID_);
create INDEX IDX_ACT_HI_PROCINST_PIID ON ACT_HI_PROCINST(PROC_INST_ID_);
*/
create INDEX IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_);
*/

SPOOL OFF

quit;
/
Original file line number Diff line number Diff line change
@@ -1,20 +1,66 @@
/*
Camunda Version: 7.3.2-ee; Oracle 12c tested
State as of: 23.02.2015
S. Hellmann, M. Krassmann: Silpion; T. Hirsch for Haspa; Ingo Richtsmeier for Camunda;
DOC.:
--------------------------------------------------------------------------------------
Create Archiving Tables in current schema
*/

WHENEVER SQLERROR EXIT SQL.SQLCODE;
SET SERVEROUTPUT ON;
-- +================================================================+
-- | STEP-2__CamundaArchiving_CREATE_Archive_Tables.sql
-- +================================================================+
-- | Camunda Version: 7.6.0; Oracle 12c tested
-- | State as of: 20.03.2017
-- | S. Hellmann, M. Krassmann: Silpion; T. Hirsch for Haspa; Ingo Richtsmeier for Camunda;
-- | Thomas Lenarz for Talanx;
-- |
-- | Changed: 25.08.2016
-- | added archive-table ARCHIVE_SOAPMESSAGES for Talanx
-- | Thomas Lenarz for Talanx
-- |
-- | Changed: 28.10.2016
-- | added column to table TMP_ARCHIVING_PROCINST:
-- | BUSINESSKEY NVARCHAR2(255)
-- | for archiving SOAPMESSAGES without processinstanceid
-- | A processinstanceid does not exist for the initial SOAP-Message
-- | since the Camunda-process is being created after it is processed.
-- |
-- | Thomas Lenarz for Talanx
-- |
-- | Changed: 07.03.2017
-- | added creation of archive tables for ACT_HI_BATCH, ACT_HI_JOB_LOG,
-- | ACT_HI_DECINST, ACT_HI_DEC_IN, ACT_DEC_OUT.
-- | Those tables were missing or were introduced in subsequent versions of
-- | Camunda not yet covered by the archiving.
-- |
-- | Thomas Lenarz for Talanx
-- |
-- | DOC.:
-- | Create Archiving Tables in current schema
-- +================================================================+

COLUMN vcomplogfile new_value vcomplogfile NOPRINT;
SELECT 'STEP-2__CamundaArchiving_CREATE_Archive_Tables_'|| TO_CHAR(SYSDATE,'DDMonYYYY_hh24_mi_ss') || '.lst' AS vcomplogfile
FROM dual;
spool &vcomplogfile

whenever sqlerror continue
whenever oserror continue
set autocommit off;
set heading off;
-- +================================================================+
show user;
select 'DATABASE = ' || sys_context('USERENV','DB_NAME') DB from dual;
-- +================================================================+
set heading on;
set echo on;
-- +================================================================+
-- +==== ENDE SQL HEADER ===========================================+
-- +================================================================+

-- Block 1 ohne Abbruch bei Fehler [z.B. drop Table....]

-- Block 2 Abbruch bei Fehler
whenever SQLERROR EXIT sql.sqlcode ROLLBACK
whenever OSERROR EXIT 20001 ROLLBACK


/*-- TMP_ARCHIVING_PROCINST */
CREATE TABLE TMP_ARCHIVING_PROCINST
( PROC_INST_ID_ NVARCHAR2(64) NOT NULL ENABLE,
BUSINESSKEY_ NVARCHAR2(255),
END_TIME_ TIMESTAMP (6)
);
CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_);
Expand All @@ -26,6 +72,19 @@ CREATE TABLE TMP_ARCHIVING_BYTEARRAY
);
CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_);

/*-- TMP_ARCHIVING_DEC */
CREATE TABLE TMP_ARCHIVING_DEC
( DEC_INST_ID_ NVARCHAR2(64) NOT NULL ENABLE,
PROC_INST_ID_ NVARCHAR2(64)
);
CREATE INDEX AI_TMP_ARCH_DEC_DI_ID ON TMP_ARCHIVING_DEC(DEC_INST_ID_);

/*-- TMP_ARCHIVING_BATCH */
CREATE TABLE TMP_ARCHIVING_BATCH
( BATCH_ID_ NVARCHAR2(64) NOT NULL ENABLE,
END_TIME_ TIMESTAMP (6)
);
CREATE INDEX AI_TMP_ARCH_BATCH_B_ID ON TMP_ARCHIVING_BATCH(BATCH_ID_);

/*--#1 ARCHIVE_ACT_HI_PROCINST; */
create TABLE ARCHIVE_ACT_HI_PROCINST
Expand Down Expand Up @@ -93,6 +152,36 @@ AS ( select * from ACT_GE_BYTEARRAY where 1=0);

create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_);

/*--#11 ARCHIVE_ACT_HI_DECINST; */
create TABLE ARCHIVE_ACT_HI_DECINST
AS ( select * from ACT_HI_DECINST where 1=0);

create index AI_HI_DECINST_PROC_INST_ID on ARCHIVE_ACT_HI_DECINST(PROC_INST_ID_);

/*--#12 ARCHIVE_ACT_HI_DEC_IN; */
create TABLE ARCHIVE_ACT_HI_DEC_IN
AS ( select * from ACT_HI_DEC_IN where 1=0);

create index AI_HI_DEC_IN_DEC_INST_ID on ARCHIVE_ACT_HI_DEC_IN(ID_);

/*--#13 ARCHIVE_ACT_HI_DEC_OUT; */
create TABLE ARCHIVE_ACT_HI_DEC_OUT
AS ( select * from ACT_HI_DEC_OUT where 1=0);

create index AI_HI_DEC_OUT_DEC_INST_ID on ARCHIVE_ACT_HI_DEC_OUT(ID_);

/*--#14 ARCHIVE_ACT_HI_BATCH; */
create TABLE ARCHIVE_ACT_HI_BATCH
AS ( select * from ACT_HI_BATCH where 1=0);

create index AI_HI_BATCH_ID on ARCHIVE_ACT_HI_BATCH(ID_);

/*--#15 ARCHIVE_ACT_HI_JOB_LOG; */
create TABLE ARCHIVE_ACT_HI_JOB_LOG
AS ( select * from ACT_HI_JOB_LOG where 1=0);

create index AI_HI_JOB_LOG on ARCHIVE_ACT_HI_JOB_LOG(ID_);

/*--------------------------------------------------------------------------------------------------
Add Meta to Archive
-------------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -163,5 +252,29 @@ alter table ARCHIVE_ACT_GE_BYTEARRAY
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID);

quit;
/
/*--#11 ARCHIVE_ACT_HI_DECINST */
alter table ARCHIVE_ACT_HI_DECINST
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_HI_DECINST_EXE_ID ON ARCHIVE_ACT_HI_DECINST(STAT_EXECUTION_ID);

/*--#12 ARCHIVE_ACT_HI_DEC_IN */
alter table ARCHIVE_ACT_HI_DEC_IN
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_HI_DEC_IN_EXE_ID ON ARCHIVE_ACT_HI_DEC_IN(STAT_EXECUTION_ID);

/*--#13 ARCHIVE_ACT_HI_DEC_OUT */
alter table ARCHIVE_ACT_HI_DEC_OUT
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_HI_DEC_OUT_EXE_ID ON ARCHIVE_ACT_HI_DEC_OUT(STAT_EXECUTION_ID);

/*--#14 ARCHIVE_ACT_HI_BATCH */
alter table ARCHIVE_ACT_HI_BATCH
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_HI_BATCH_EXE_ID ON ARCHIVE_ACT_HI_BATCH(STAT_EXECUTION_ID);

/*--#15 ARCHIVE_ACT_HI_JOB_LOG */
alter table ARCHIVE_ACT_HI_JOB_LOG
add (STAT_EXECUTION_ID NUMBER(20), STAT_EXECUTION_TS TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP );
CREATE INDEX AI_ACT_HI_JOB_LOG_EXE_ID ON ARCHIVE_ACT_HI_JOB_LOG(STAT_EXECUTION_ID);

SPOOL OFF
Loading

0 comments on commit 7bf997c

Please sign in to comment.