• Execute the main method of the DbSchemaCreate class
However, often only database administrators can execute DDL statements on a database. On a production system, this is also the
wisest of choices. The SQL DDL statements can be found on the Activiti downloads page or inside the Activiti distribution folder, in the
database subdirectory. The scripts are also in the engine jar (activiti-engine-x.jar), in the package org/activiti/db/create (the drop
folder contains the drop statements). The SQL files are of the form
Where db is any of the supported databases and type is
• engine: the tables needed for engine execution. Required.
• identity: the tables containing users, groups and memberships of users to groups. These tables are optional and should be used
when using the default identity management as shipped with the engine.
• history: the tables that contain the history and audit information. Optional: not needed when history level is set to none. Note that
this will also disable some features (such as commenting on tasks) which store the data in the history database.
Note for MySQL users: MySQL version lower than 5.6.4 has no support for timestamps or dates with millisecond precision. To make
things even worse, some version will throw an exception when trying to create such a column but other versions don’t. When doing
auto-creation/upgrade, the engine will change the DDL when executing it. When using the DDL file approach, both a regular version
and a special file with mysql55 in it are available (this applies on anything lower than 5.6.4). This latter file will have column types with
no millisecond precision in it.
Concretely, the following applies for MySQL version
• <5.6: No millisecond precision available. DDL files available (look for files containing mysql55). Auto creation/update will work out
of the box.
• 5.6.0 - 5.6.3: No millisecond precision available. Auto creation/update will NOT work. It is advised to upgrade to a newer database
version anyway. DDL files for mysql 5.5 could be used if really needed.
• 5.6.4+: Millisecond precision available. DDL files available (default file containing mysql). Auto creation/update works out of the
box.
Do note that in the case of upgrading the MySQL database later on and the Activiti tables are already created/upgraded, the column
type change will have to be done manually!
3.7. Database table names explained
The database names of Activiti all start with ACT_. The second part is a two-character identification of the use case of the table. This
use case will also roughly match the service API.
• ACT_RE_*: RE stands for repository . Tables with this prefix contain static information such as process definitions and process
resources (images, rules, etc.).
• ACT_RU_*: RU stands for runtime . These are the runtime tables that contain the runtime data of process instances, user tasks,
variables, jobs, etc. Activiti only stores the runtime data during process instance execution, and removes the records when a
process instance ends. This keeps the runtime tables small and fast.
• ACT_ID_*: ID stands for identity . These tables contain identity information, such as users, groups, etc.
• ACT_HI_*: HI stands for history . These are the tables that contain historic data, such as past process instances, variables,
tasks, etc.
• ACT_GE_*: general data, which is used in various use cases.
3.8. Database upgrade
Make sure you make a backup of your database (using your database backup capabilities) before you run an upgrade.
By default, a version check will be performed each time a process engine is created. This typically happens once at boot time of your
application or of the Activiti webapps. If the Activiti library notices a difference between the library version and the version of the Activiti
database tables, then an exception is thrown.
To upgrade, you have to start with putting the following configuration property in your activiti.cfg.xml configuration file:
activiti.{db}.{create|drop}.{type}.sql
1
2
3
4
5
6
7
8
9
<beans >
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- ... -->
<property name="databaseSchemaUpdate" value="true" />
<!-- ... -->
</bean>
</beans>