Skip to content

Commit

Permalink
Use DbUpgradeStep for the channel definition type and implementation …
Browse files Browse the repository at this point in the history
…upgrade
  • Loading branch information
filiphr committed Sep 26, 2024
1 parent bd2984f commit 3272edf
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,11 @@ protected String schemaUpdateInLock() {

boolean isEngineTablePresent = isEngineTablePresent();

ChangeLogVersion changeLogVersion = null;
String dbVersion = null;
if (isEngineTablePresent) {
dbVersion = getDbVersion();
if (dbVersion == null) {
changeLogVersion = getChangeLogVersion();
dbVersion = changeLogVersion.dbVersion();
dbVersion = getChangeLogVersion().dbVersion();
}
}

Expand All @@ -155,8 +153,6 @@ protected String schemaUpdateInLock() {
if (isUpgradeNeeded) {
// Engine upgrade
dbSchemaUpgrade(context, matchingVersionIndex, dbVersion);
dbSchemaUpgraded(changeLogVersion);

feedback = "upgraded Flowable from " + dbVersion + " to " + getEngineVersion();

} else if (!isEngineTablePresent) {
Expand All @@ -171,10 +167,6 @@ public String getContext() {
return context;
}

protected void dbSchemaUpgraded(ChangeLogVersion changeLogVersion) {

}

public boolean isEngineTablePresent() {
return isTablePresent(getEngineTableName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.apache.commons.io.IOUtils;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.impl.context.Context;
import org.flowable.common.engine.impl.db.DbUpgradeStep;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.eventregistry.api.ChannelDefinition;
Expand All @@ -31,7 +33,12 @@
/**
* @author Filip Hrisafov
*/
public class UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd implements Command<Void> {
public class UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd implements Command<Void>, DbUpgradeStep {

@Override
public void execute() throws Exception {
execute(Context.getCommandContext());
}

@Override
public Void execute(CommandContext commandContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.flowable.common.engine.impl.AbstractEngineConfiguration;
import org.flowable.common.engine.impl.db.EngineSchemaManagerLockConfiguration;
import org.flowable.common.engine.impl.db.EngineSqlScriptBasedDbSchemaManager;
import org.flowable.eventregistry.impl.EventRegistryEngine;
import org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd;
import org.flowable.eventregistry.impl.util.CommandContextUtil;

public class EventDbSchemaManager extends EngineSqlScriptBasedDbSchemaManager {
Expand Down Expand Up @@ -71,18 +69,6 @@ protected String getDbVersionForChangelogVersion(String changeLogVersion) {
return "6.5.0.0";
}

protected AbstractEngineConfiguration getEngineConfiguration() {
return CommandContextUtil.getEventRegistryConfiguration();
}

@Override
protected void dbSchemaUpgraded(ChangeLogVersion changeLogVersion) {
String version = changeLogVersion.version();
if ("1".equals(version) || "2".equals(version)) {
getEngineConfiguration().getCommandExecutor().execute(new UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd());
}
}

@Override
protected String getResourcesRootDirectory() {
return "org/flowable/eventregistry/db/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ VARCHAR(255);

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_CHANNEL_DEFINITION');

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE FLW_CHANNEL_DEFINITION ADD TYPE_ VARCHAR(255);

ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ VARCHAR(255);

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE FLW_CHANNEL_DEFINITION ADD TYPE_ varchar(255);

ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ varchar(255);

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE FLW_CHANNEL_DEFINITION ADD TYPE_ VARCHAR(255) NULL;

ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ VARCHAR(255) NULL;

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE FLW_CHANNEL_DEFINITION ADD TYPE_ VARCHAR2(255);

ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ VARCHAR2(255);

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ALTER TABLE FLW_CHANNEL_DEFINITION ADD TYPE_ VARCHAR(255);

ALTER TABLE FLW_CHANNEL_DEFINITION ADD IMPLEMENTATION_ VARCHAR(255);

execute java org.flowable.eventregistry.impl.cmd.UpdateChannelDefinitionTypeAndImplementationForAllChannelDefinitionsCmd

0 comments on commit 3272edf

Please sign in to comment.