Hello,
I am developing a spring boot app and I want to create the schema of my db by calling some method of flowable.
E.g ProcessDbSchemaManager schemaManager = new ProcessDbSchemaManager(); schemaManager.schemaCreate();
Hello @filiphr ,
I want to use AbstractRoutingDataSource of spring jpa which only creates schema for the default datasource and not for the datasources of different tenants. So, I wanted to create the schema when a new tenant/datasource is registered.
where dataSource is a bean of type AbstractRoutingDataSource and then I override processEngineConfiguration like that:
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(DataSource dataSource,
PlatformTransactionManager transactionManager) {
SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
configuration.setDataSource(dataSource);
configuration.setTransactionManager(transactionManager);
configuration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
configuration.setAsyncExecutorActivate(false);
// Build the process engine once for all tenants
configuration.buildProcessEngine();
return configuration;
}
And the default db is created by triggering schemaCreate method of Flowable but not the rest of the target datasources. So, I was thinking to loop over my target datasources and initiliaze the schema for all of them, if that makes sense
In order to make this work you’ll have to make sure that when Flowable needs a DB connection the correct datasource will get resolved. If you look at how the Flowable TenantAwareDataSource works and how the MultiSchemaMultiTenantProcessEngineConfiguration is initializing the schemas for each tenant you’ll see that first it sets the tenant, which leads tot he TenantAwareDataSource to use provide the right datasource for the current tenant. You need to do the same when using something else.