Hi Michael,
I wrote a small summary giving an overview of the current database change management implementation of camunda bpm and the involved qa steps.
First, we run tests against following databases:
- db2 9.7
- mysql 5.x
- mssql 2008 and 2012
- postgresql 9
- oracle 10g and 11g
- h2
Overview of maven modules using/testing database integration and their invocation using maven:
ENGINE
engine/pom.xml mvn clean install -Ddatabase=${database}
ENGINE-IT-XA
qa/pom.xml mvn clean install -P${runtime},${database},engine-integration,clean-db -Ddatabase.host=xxxx -Ddatabase.port=xxxx -Ddatabase.name=xxxx -Ddatabase.user=xxx -Ddatabase.password=xxxx
WEBAPPS-UNIT
webapps/camunda-webapp/webapp/pom.xml mvn clean install -Ddatabase=${database}
WEBAPPS-IT
qa/pom.xml mvn clean install -P${runtime},${database},webapps-integration,clean-db -Ddatabase.host=xxxx -Ddatabase.port=xxxx -Ddatabase.name=xxxx -Ddatabase.user=xxx -Ddatabase.password=xxxx
DB-INSTANCE-MIGRATION
qa/test-db-instance-migration/pom.xml mvn clean install -Pupgrade,${database}
DB-UPGRADE-TEST
qa/test-db-upgrade/pom.xml mvn clean install -Pupgrade,70,${database} -Dtest.version.old=6.2.4 -Dtest.version.old.major=6.2
DISTRO-SQL-SCRIPTS
distro/sql-script/pom.xml mvn clean install
Example for maven parameters:
-Ddatabase.host=localhost
-Ddatabase.port=3306
-Ddatabase.name=myEngineDb
-Ddatabase.user=myUser
-Ddatabase.password=myPassword
Allowed values for placeholders above (see corresponding maven pom for actual values):
- ${database}
- db2
- mysql
- mssql
- mssql12
- postgresql
- oracle10g
- oracle
- h2
- ${runtime}
ENGINE
The Engine module is the core of camunda-bpm-platform. It contains the process engine but also the core bpm-platform implementation.
The org.camunda.bpm.engine.ProcessEngineConfiguration class and it's implementation org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl contains several contants for specifying the database schema mechanism:
DB_SCHEMA_UPDATE_FALSE = "false"; // skip schema creation but check if version specified in ProcessEngine.VERSION matches with the one in database table 'ACT_GE_PROPERTY'
DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop"; // create schema on startup and drop it on shutdown
DB_SCHEMA_UPDATE_TRUE = "true"; // update schema - NOT USED ATM
DB_SCHEMA_UPDATE_CREATE = "create"; // create schema on startup
DB_SCHEMA_UPDATE_DROP_CREATE = "drop-create"; // drop schema on startup and recreate it afterwards
During the intialization of the process engine, the command 'SchemaOperationsProcessEngineBuild' will always be executed.
When the process engine method 'close' is invoked, the command 'SchemaOperationsProcessEngineClose' will be executed.
They use methods defined in 'org.camunda.bpm.engine.impl.db.DbSqlSession', so it will be a good starting point to investigate the current database change mechanism.
At the moment an automatic 'migration' mechanism is non-existent, because we disabled the activiti upgrade mechanism in the past.
So we only support database schema creation and dropping.
The database create/drop scripts used in the schema operations are located at ${camunda-bpm-platform}/engine/src/main/resources/org/camunda/bpm/engine/db folder.
The activiti upgrade mechanism used a property stored in 'ACT_GE_PROPERTY' to bind the actual database schema to a version.
When upgrade is enabled, the engine checks on start up for a version difference and upgrades to the latest database schema using the provided upgrade scripts.
Hint:
The MyBatis mappings are located in ${camunda-bpm-platform}/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping but I think there is no need to touch them when switching to Liquibase.
ENGINE DATABASE TESTING
The engine maven module contains the profile 'database' and some profiles for including the necessary database drivers.
The 'database' profile requires a java properties file located at ${user.home}/.camunda/jdbc/engine.${database}.properties
It requires the following properties to be set:
- jdbc.url
- jdbc.driver
- jdbc.username
- jdbc.password
A DB2 Example:
jdbc.url=jdbc:db2://localhost:50000/ENGI70
jdbc.driver=com.ibm.db2.jcc.DB2Driver
jdbc.username=myDbUser
jdbc.password=myDbPassword
The location of the file can be overridden by specifying property '-Ddb.properties.file=${pathToPropertiesFile}' when executing maven.
ENGINE-IT-XA
The ENGINE-IT-XA tests the camunda-bpm-platform and it's container integration. We run a test matrix against all supported containers and databases.
WEBAPPS-UNIT
It tests the different webapps shipped with camunda-bpm against the different databases.
Uses the same mechanism to specify the test properties as the ENGINE module.
It requires a properties file placed in '${user.home}/.camunda/jdbc/cockpit.${database}.properties' which contains
jdbc.url=jdbc:db2://db2.camunda.loc:50000/CPIT70
jdbc.driver=com.ibm.db2.jcc.DB2Driver
jdbc.username=cpit70
jdbc.password=CaCockpit70
or the location of the file can be overridden by specifying property '-Ddb.properties.file=${pathToPropertiesFile}' when executing maven.
WEBAPPS-IT
Tests the different webapps using Selenium / simulate user interaction.
DB-INSTANCE-MIGRATION
Tests the migration from camunda-fox to camunda-bpm using a database schema from camunda-fox v6.2 to start some processes.
Then it starts a camunda-bpm engine and tests that the same behaviour is still valid for camunda-bpm v7.0.
ATTENTION: Needs access to camunda-fox enterprise edition nexus repositories.
DB-UPGRADE-TEST
The DB-UPGRADE-TEST tests the migration of the database schema.
It uses the maven-sql-plugin to create the old database schema, executes the ENGINE testsuite on it, then uses the maven-sql-plugin again to execute the corresponding database upgrade script.
ATTENTION: Needs access to camunda-fox enterprise edition nexus repositories.
DISTRO-SQL-SCRIPTS
The DISTRO-SQL-SCRIPTS contains the upgrade scripts for the camunda-bpm-platform.
It uses maven to create a JAR file to bundle the create/drop/upgrade scripts using the scripts in the module and from ENGINE module.
During the build, it merges the engine and history script for each database in a single sql file.
The resulting JAR file is used during the assembly of the distro to include the sql scripts.
WRAP-UP LIQUIBASE INTEGRATION
When you implement the Liquibase solution, you must take care of/maintain compability with:
multi-tenancy (it is a requirement to allow the creation of tables with a user specified prefix, because it is a part of the current multi-tenancy implementation)
allow the user to specify which tables should be created (engine, history, identity), because not every user needs all
Imo with Liquibase we can probably drop the DISTRO-SQL-SCRIPTS module and a lot of magic located in org.camunda.bpm.engine.impl.db.DbSqlSession but this is just a guess by me, you have more experience with Liquibase. We should also drop maven-sql-plugin usage in favor of the maven-liquibase-plugin in all affected modules.
I think the camunda-bpm team responsibility for this is to refactor the DB-INSTANCE-MIGRATION / DB-UPGRADE-TEST modules to the Liquibase integration because they still require credentials to access camunda-fox-ee repository, so this leaves you with 'engine'-module and all the maven modules mentioned above minus the DB-INSTANCE-MIGRATION / DB-UPGRADE-TEST modules.
Cheers,
Christian