Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)

122111 arebegea: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4)
      122110 arebegea: Merged V4.2.6 (4.2.6) to V4.2-BUG-FIX (4.2.7)
         122020 aleahu: MNT-15144 : Workflow filters are not working for the activiti workflows after upgrade from 4.1.10
            - Added an upgrade script that moves missing workflow variables from act_hi_detail to act_hi_varinst
            - Only the most recent version of a workflow variable should be moved to act_hi_varinst, only if not already present
            


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@122118 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrei Rebegea
2016-02-11 16:07:15 +00:00
parent 76240ffd6b
commit 01454653d3
6 changed files with 172 additions and 2 deletions

View File

@@ -82,6 +82,7 @@
<ref bean="patch.db-V4.1-rename-constraint-activiti" />
<ref bean="patch.db-V4.2-add-activti-index-historic-activity" />
<ref bean="patch.db-V4.2-upgrade-to-activiti-5.11" />
<ref bean="patch.db-v4.2-migrate-activiti-workflows" />
<ref bean="patch.db-V4.2-remove-old-index-act" />
<ref bean="patch.db-V4.2-upgrade-to-activiti-5.13" />
<ref bean="patch.db-V5.0-upgrade-to-activiti-5.16.2" />

View File

@@ -0,0 +1,76 @@
--
-- Title: Migrate old workflow details into act_hi_varinst
-- Database: MySQL
-- Since: V4.2 Schema 6080
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- Migrate old workflow details into act_hi_varinst
--ASSIGN:START_INDEX=VALUE_
SELECT VALUE_ FROM act_ge_property WHERE NAME_ = 'next.dbid';
--count the current items in act_hi_varinst, before migration
--ASSIGN:INITIAL_ROW_COUNT=ROW_COUNT
select count(*) as ROW_COUNT from act_hi_varinst;
-- insert from act_hi_detail into act_hi_varinst, the id will be generated starting from the next.dbid
-- only the most recent version of a variable must by migrated
-- the most recent version of a variable is considered the be the one with the highest revision and timestamp
INSERT INTO act_hi_varinst(
ID_,
PROC_INST_ID_,
EXECUTION_ID_,
TASK_ID_,
NAME_,
VAR_TYPE_,
REV_,
BYTEARRAY_ID_,
DOUBLE_,
LONG_,
TEXT_,
TEXT2_
)
SELECT
(@cnt := @cnt + 1),
PROC_INST_ID_,
EXECUTION_ID_,
TASK_ID_,
NAME_,
VAR_TYPE_,
REV_,
BYTEARRAY_ID_,
DOUBLE_,
LONG_,
TEXT_,
TEXT2_
FROM ACT_HI_DETAIL AHD
CROSS JOIN (SELECT @cnt := ${START_INDEX} + 1) AS dummy
WHERE AHD.PROC_INST_ID_ not in (select PROC_INST_ID_ from ACT_HI_VARINST)
AND
(AHD.PROC_INST_ID_ , AHD.NAME_, AHD.REV_, AHD.time_) IN
(SELECT PROC_INST_ID_, NAME_, MAX(REV_), MAX(time_)
FROM ACT_HI_DETAIL
GROUP BY PROC_INST_ID_ , NAME_);
--update act_ge_property
--ASSIGN:TOTAL_ROW_COUNT=ROW_COUNT
select count(*) as ROW_COUNT from act_hi_varinst;
--increase the next.dbid value so that following ids will be created starting with the new value
update act_ge_property set value_ = value_ + ${TOTAL_ROW_COUNT} - ${INITIAL_ROW_COUNT} where NAME_ = 'next.dbid';
--revision is currently increased each time a block id is reserved, so we're simulating this behaviour
update act_ge_property set rev_ = value_ DIV 100 + 1 where NAME_ = 'next.dbid';
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-v4.2-migrate-activiti-workflows';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-v4.2-migrate-activiti-workflows', 'Manually executed script upgrade V4.2: migrate-activiti-workflows',
0, 6080, -1, 6081, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
);

View File

@@ -0,0 +1,80 @@
--
-- Title: Migrate old workflow details into act_hi_varinst
-- Database: PostgreSQL
-- Since: V4.2 Schema 6080
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- Migrate old workflow details into act_hi_varinst
--ASSIGN:START_INDEX=VALUE_
SELECT VALUE_ FROM act_ge_property WHERE NAME_ = 'next.dbid';
CREATE SEQUENCE VARINST_ID_SEQ START ${START_INDEX};
--count the current items in act_hi_varinst, before migration
--ASSIGN:INITIAL_ROW_COUNT=ROW_COUNT
select count(*) as ROW_COUNT from act_hi_varinst;
-- increment the value to be used by the indexes with 1;
select nextval('VARINST_ID_SEQ');
-- insert from act_hi_detail into act_hi_varinst, the id will be generated starting from the next.dbid
-- only the most recent version of a variable must by migrated
-- the most recent version of a variable is considered to be the one with the highest revision and timestamp
INSERT INTO act_hi_varinst(
ID_,
PROC_INST_ID_,
EXECUTION_ID_,
TASK_ID_,
NAME_,
VAR_TYPE_,
REV_,
BYTEARRAY_ID_,
DOUBLE_,
LONG_,
TEXT_,
TEXT2_
)
SELECT
nextval('VARINST_ID_SEQ'),
PROC_INST_ID_,
EXECUTION_ID_,
TASK_ID_,
NAME_,
VAR_TYPE_,
REV_,
BYTEARRAY_ID_,
DOUBLE_,
LONG_,
TEXT_,
TEXT2_
FROM ACT_HI_DETAIL AHD
WHERE AHD.PROC_INST_ID_ not in (select PROC_INST_ID_ from ACT_HI_VARINST)
AND
(AHD.PROC_INST_ID_ , AHD.NAME_, AHD.REV_, AHD.time_) IN
(SELECT PROC_INST_ID_, NAME_, MAX(REV_), MAX(time_)
FROM ACT_HI_DETAIL
GROUP BY PROC_INST_ID_ , NAME_);
--update act_ge_property
--ASSIGN:TOTAL_ROW_COUNT=ROW_COUNT
select count(*) as ROW_COUNT from act_hi_varinst;
--increase the next.dbid value so that following ids will be created starting with the new value
update act_ge_property set value_ = value_::integer + ${TOTAL_ROW_COUNT} - ${INITIAL_ROW_COUNT} where NAME_ = 'next.dbid';
--revision is currently increased each time a block id is reserved, so we're simulating this behaviour
update act_ge_property set rev_ = value_::integer / 100 + 1 where NAME_ = 'next.dbid';
DROP SEQUENCE IF EXISTS VARINST_ID_SEQ;
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-v4.2-migrate-activiti-workflows';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-v4.2-migrate-activiti-workflows', 'Manually executed script upgrade V4.2: migrate-activiti-workflows',
0, 6080, -1, 6081, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
);

View File

@@ -386,4 +386,6 @@ patch.addSurfConfigFolders.description=Adds 'cm:extensions' and 'cm:module-deplo
patch.spacesBootstrapSmartDownloadFolder.description=Adds Smart Download Folder in Data Dictionary.
patch.spacesBootstrapSmartTemplatesFolder.description=Adds Smart Templates Folder in Data Dictionary.
patch.spacesBootstrapSmartFolderExample.description=Adds smartFoldersExample.json file in Smart Templates Folder.
patch.spacesBootstrapSmartFolderExample.description=Adds smartFoldersExample.json file in Smart Templates Folder.
patch.db-v4.2-migrate-activiti-workflows.description=Migrated workflow variables into newly created table.

View File

@@ -1415,4 +1415,15 @@
</list>
</property>
</bean>
<bean id="patch.db-v4.2-migrate-activiti-workflows" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-v4.2-migrate-activiti-workflows</value></property>
<property name="description"><value>patch.db-v4.2-migrate-activiti-workflows.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>9027</value></property>
<property name="targetSchema"><value>9028</value></property>
<property name="scriptUrl">
<value>classpath:alfresco/dbscripts/upgrade/4.2/${db.script.dialect}/migrate-activiti-workflows.sql</value>
</property>
</bean>
</beans>

View File

@@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@
# Schema number
version.schema=9027
version.schema=9028