Create db schema manually

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();

Is this possible?
I tried also creating the schema by using the postgres sql file from here: flowable-engine/modules/flowable-engine/src/main/resources/org/flowable/db/create/flowable.postgres.create.engine.sql at main · flowable/flowable-engine · GitHub
but it didn’t work either

Hey @desp.kaz,

Why do you need to do this manually? Why aren’t you relying on what Flowable is providing out-of-the-box?

Cheers,
Filip

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.

I’m not following the purpose of this.

If you do not have the schema created for the other tenants, how will this work?

AbstractRoutingDataSource by default only creates the schema of the default datasource.
So, I registered all datasources like that:

  dataSource.setDefaultTargetDataSource(targetDataSources.values().iterator().next());
        dataSource.setTargetDataSources(targetDataSources);

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.