cancel
Showing results for 
Search instead for 
Did you mean: 

configuring database schema to something ELSE than 'public'

ttfrttfr
Champ in-the-making
Champ in-the-making
I am using Postgresql and I would like to put the activiti database in another schema than the default "public" schema.
I am using Spring as configuration of engine and I did not find any property to configure this.

can you help?

Sorry if the question was already asked many times, I have searched the forum for "database schema, modification, change etc…" and of course it brings too many results.

Thanks,

Thomas
17 REPLIES 17

jbarrez
Star Contributor
Star Contributor
On the processEngineConfiguration bean you can set a table prefix:

  /**
   * Allows configuring a database table prefix which is used for all runtime operations of the process engine.
   * For example, if you specify a prefix named 'PRE1.', activiti will query for executions in a table named
   * 'PRE1.ACT_RU_EXECUTION_'.
   *
   * <p />
   * <strong>NOTE: the prefix is not respected by automatic database schema management. If you use
   * {@link ProcessEngineConfiguration#DB_SCHEMA_UPDATE_CREATE_DROP}
   * or {@link ProcessEngineConfiguration#DB_SCHEMA_UPDATE_TRUE}, activiti will create the database tables
   * using the default names, regardless of the prefix configured here.</strong> 
   *
   * @since 5.9
   */
  public ProcessEngineConfiguration setDatabaseTablePrefix(String databaseTablePrefix) {
    this.databaseTablePrefix = databaseTablePrefix;
    return this;
  }


I know this works on other database to change the schema. Would that work for postgres too (not an expert on postgres)?

ttfrttfr
Champ in-the-making
Champ in-the-making
I did not succeed in configuring this property through the Spring processEngineConfiguration, it says this property is unknown.
I assume I should then setting it up at runtime…

jbarrez
Star Contributor
Star Contributor
Are you sure? SpringProcessEngineConfiguration extends from ProcessEngineConfigurationImpl, which has

  public ProcessEngineConfiguration setDatabaseTablePrefix(String databaseTablePrefix) {
    this.databaseTablePrefix = databaseTablePrefix;
    return this;
  }

So, <property name="databaseTablePrefix" value="blah" /> should work …

udhayakumar_t
Champ in-the-making
Champ in-the-making
where to find the tables used in activiti? Currently i am  trying to setup activiti in local using MYSQL database. In the user guide, the following sets are mentioned.

Add the activiti-engine jars to your classpath
Add a suitable database driver
Add an Activiti configuration file (activiti.cfg.xml) to your classpath, pointing to your database (see database configuration section)
Execute the main method of the DbSchemaCreate class

However, i couldn't find the class DbSchemaCreate nowhere

jbarrez
Star Contributor
Star Contributor
The easiest way is letting the engine do it for you, by adding this property to your process engine confi:

<code>
<property name="databaseSchemaUpdate" value="true" />   
</code>

arlen_bales
Champ in-the-making
Champ in-the-making
databaseTablePrefix  - this property does not provide any functionality on schemas, this is simply a TABLE prefix.
databaseSchema - schema for activiti tables.
databaseSchemaUpdate - true, will create the default DB if not present or will update it.

database creation/update - database creation will not take into account databaseSchema, it will create everything into "public" schema.
For instance if you DB2 and public schema is R2, tables will be created there but queries after deploy will fail if you wont have databaseSchema = R2.

jbarrez
Star Contributor
Star Contributor
In DB2, I believe the 'currentSchema' is configured through the jdbc connection, right?

balunadig
Champ in-the-making
Champ in-the-making
Using activiti 5.14 and H2 database.  I would like to be able to create the activiti tables in a named schema.

I have specified "databaseSchema" as follows in my camel-config.xml 

property name="databaseSchema" value="activitiSchema"

And I get "couldn't create db schema" when the war gets deployed…

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.activiti.engine.ActivitiException: couldn't create db schema:
create table ACT_GE_PROPERTY (
NAME_ varchar(64),
VALUE_ varchar(300),
REV_ integer,
primary key (NAME_)
)

jbarrez
Star Contributor
Star Contributor
H2 doesn't work like that. In h2 your jdbc url determines the schema automatically.