Database Configuration

1. Overview

The Provision Portal uses external relational databases to store application data and manage internal workflow engine state. Supported database systems include MySQL-compatible databases and Oracle SQL, provided that the appropriate JDBC driver is included in the project dependencies. The application does not create these databases; it relies on existing instances configured and maintained externally by ACS or manually via Liquibase.

Spring Boot configuration properties are used to define separate data sources for application-level persistence and for the Flowable process engine. These are automatically recognized by Spring and Flowable without requiring additional setup.

The default database is minimal and contains only two application-specific tables:

  1. prov — storing information about provision;

  2. status — storing information about execution status.

It is not designed as a per-service database and may be shared with other systems or external applications that require access to the Provision Portal’s data.

1.1. Copy Columns of prov

A request can list one object more than once (see copies of one object). Two columns of prov tell these copies apart:

Column Meaning

objectcopy

In an object row, the number of the copy among the copies of the same service and object id of the device. In a sub-object row, the copy of the parent object.

subobjectcopy

In a sub-object row, the number of the copy among the copies of the same sub-object id under the parent copy.

Every other row has 1 in both columns: parameter, service, info and domain rows. An object row has 1 in subobjectcopy. A row written before the upgrade is copy 1.

The application adds the columns itself: at every start it checks prov and adds each column the table lacks. After a start that added them, the log says:

Table prov: column objectcopy added
Table prov: column subobjectcopy added

For this, the application must connect to the default database as the owner of the ACS schema, as it does by default. On a large prov the first start can take longer: the database normally changes only the table definition, but in some table layouts it rebuilds the table.

When the application cannot add a column, it does not start. Its log names the column, gives the two reasons of the database in brackets and the statement to run. For objectcopy on MySQL, with a database user that may not alter the table:

Table prov: the portal could not read the column objectcopy (Unknown column 'objectcopy' in 'field list') and could not add it (ALTER command denied to user 'provision'@'10.0.0.5' for table 'prov'). If the table lacks the column, run this statement as the owner of the ACS schema and start the portal again: ALTER TABLE prov ADD COLUMN objectcopy int unsigned NOT NULL DEFAULT 1

A session that keeps a transaction on prov open holds the statement back. The application waits for it up to 60 seconds, then does not start, and the second reason in the log line is the one of the database, on MySQL Lock wait timeout exceeded; try restarting transaction. Start the application again when the table is free.

To add the columns by hand, run the statements as the owner of the ACS schema, then start the application again.

MySQL:

ALTER TABLE prov ADD COLUMN objectcopy int unsigned NOT NULL DEFAULT 1;
ALTER TABLE prov ADD COLUMN subobjectcopy int unsigned NOT NULL DEFAULT 1;

Oracle:

ALTER TABLE prov ADD (objectcopy NUMBER(11) DEFAULT 1 NOT NULL);
ALTER TABLE prov ADD (subobjectcopy NUMBER(11) DEFAULT 1 NOT NULL);

When several instances of the application start together, one of them adds the columns and the others find them in place.

An older version of the portal on an upgraded database does not know the columns. Its new rows are copy 1. Once a device has two or more copies of one object, an older version cannot save that object correctly: depending on the version, the provisioning run of the device fails and the log says Saving provisions failed!, or the portal writes the same values into every copy of the object. After the upgrade, do not go back to an older version.

2. Configuration

Provision Portal now ships two dedicated Spring profiles: application-mysql.yml and application-oracle.yml. Select the profile through SPRING_PROFILES_ACTIVE (or spring.profiles.active) and Spring Boot will load one of the following configurations.

  • default — business data stored in the ACS schema (provision/status tables).

  • flowable — Flowable engine metadata (deployments, jobs, runtime data).

Both profiles inherit the same HTTP/HTTPS settings and reuse the shared pool properties.

2.1. Default (ACS) datasource excerpt

application-mysql.yml
spring:
  datasource:
    default:
      jdbcUrl: ${MYSQL_JDBC_URL:jdbc:mysql://${MYSQL_HOST:${DB_HOST:localhost}}:${MYSQL_PORT:3306}/${MYSQL_SCHEMA:ftacs}?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=${DB_TIMEZONE:Europe/Kiev}}
      username: ${MYSQL_USER:ftacs}
      password: ${MYSQL_PASSWORD:ftacs}
      driver-class-name: ${MYSQL_DRIVER_CLASS_NAME:com.mysql.cj.jdbc.Driver}
      maximum-pool-size: ${DB_MAX_POOL_SIZE:10}
      minimum-idle: ${DB_MIN_IDLE:5}
      connection-timeout: ${DB_CONNECTION_TIMEOUT_MS:30000}
application-oracle.yml
spring:
  datasource:
    default:
      jdbcUrl: ${ORACLE_JDBC_URL:jdbc:oracle:thin:@//${ORACLE_HOST:${DB_HOST:localhost}}:${ORACLE_PORT:1521}/${ORACLE_SERVICE:XEPDB1}}
      username: ${ORACLE_USER:ftacs}
      password: ${ORACLE_PASSWORD:ftacs}
      driver-class-name: ${ORACLE_DRIVER_CLASS_NAME:oracle.jdbc.OracleDriver}

2.2. Flowable datasource excerpt

spring:
  datasource:
    flowable:
      jdbcUrl: ${FLOWABLE_MYSQL_JDBC_URL:jdbc:mysql://${FLOWABLE_MYSQL_HOST:${FLOWABLE_DB_HOST:${DB_HOST:localhost}}}:${FLOWABLE_MYSQL_PORT:${MYSQL_PORT:3306}}/${FLOWABLE_MYSQL_SCHEMA:flowable}?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=${DB_TIMEZONE:Europe/Kiev}}
      username: ${FLOWABLE_MYSQL_USER:flowable}
      password: ${FLOWABLE_MYSQL_PASSWORD:flowable}
      driver-class-name: ${FLOWABLE_MYSQL_DRIVER_CLASS_NAME:com.mysql.cj.jdbc.Driver}
      maximum-pool-size: ${FLOWABLE_DB_MAX_POOL_SIZE:${DB_MAX_POOL_SIZE:10}}
      minimum-idle: ${FLOWABLE_DB_MIN_IDLE:${DB_MIN_IDLE:5}}
      connection-timeout: ${FLOWABLE_DB_CONNECTION_TIMEOUT_MS:${DB_CONNECTION_TIMEOUT_MS:30000}}

Oracle values mirror these placeholders using the FLOWABLE_ORACLE_* variables. Set FLOWABLE_DB_HOST when the Flowable schema lives on a different server than the ACS schema.

2.3. Environment Variables

2.3.1. Shared pool settings

Variable Description

DB_MAX_POOL_SIZE

Upper bound for the ACS datasource pool. Default 10.

DB_MIN_IDLE

Minimum warm connections in the ACS pool. Default 5.

DB_CONNECTION_TIMEOUT_MS

How long to wait for a connection before failing a request. Default 30000 ms.

FLOWABLE_DB_MAX_POOL_SIZE, FLOWABLE_DB_MIN_IDLE, FLOWABLE_DB_CONNECTION_TIMEOUT_MS

Flowable-specific overrides. Inherit the shared values when unset.

DB_HOST, FLOWABLE_DB_HOST

Fallback hostnames used by the profile-specific variables.

DB_TIMEZONE

Database server timezone used in the MySQL JDBC connection string (serverTimezone parameter). Default Europe/Kiev.

2.3.2. MySQL profile

Variable Description

MYSQL_JDBC_URL

Full JDBC override. Leave empty to synthesize a URL from host/port/schema.

MYSQL_HOST, MYSQL_PORT

Server address for the ACS schema. Defaults to DB_HOST/3306.

MYSQL_SCHEMA

Schema (database) name that stores prov and status. Default ftacs.

MYSQL_USER, MYSQL_PASSWORD

Credentials for the ACS datasource. Defaults ftacs/ftacs.

MYSQL_DRIVER_CLASS_NAME

Driver class. Keep com.mysql.cj.jdbc.Driver for MySQL-compatible engines.

2.3.3. Oracle profile

Variable Description

ORACLE_JDBC_URL

Full JDBC override (jdbc:oracle:thin:@//…​). Overrides host/port/service.

ORACLE_HOST, ORACLE_PORT

Listener endpoint. Defaults to DB_HOST/1521.

ORACLE_SERVICE

Service name or SID that exposes the ACS schema. Default XEPDB1.

ORACLE_USER, ORACLE_PASSWORD

Credentials for the ACS schema. Defaults to ftacs.

ORACLE_DRIVER_CLASS_NAME

Driver class (oracle.jdbc.OracleDriver).

2.3.4. Flowable (MySQL)

Use the same pattern to point Flowable to another server or schema.

Variable Description

FLOWABLE_MYSQL_JDBC_URL

Override for the Flowable JDBC string.

FLOWABLE_MYSQL_HOST, FLOWABLE_MYSQL_PORT, FLOWABLE_MYSQL_SCHEMA

Components for the Flowable schema. Defaults to FLOWABLE_DB_HOST, 3306, flowable.

FLOWABLE_MYSQL_USER, FLOWABLE_MYSQL_PASSWORD

Flowable credentials. Default flowable/flowable.

FLOWABLE_MYSQL_DRIVER_CLASS_NAME

Driver class for Flowable when using MySQL (com.mysql.cj.jdbc.Driver).

2.3.5. Flowable (Oracle)

Variable Description

FLOWABLE_ORACLE_JDBC_URL

Complete Oracle JDBC string override.

FLOWABLE_ORACLE_HOST, FLOWABLE_ORACLE_PORT, FLOWABLE_ORACLE_SERVICE

Oracle listener/service for the Flowable schema.

FLOWABLE_ORACLE_USER, FLOWABLE_ORACLE_PASSWORD

Credentials for Flowable tables.

FLOWABLE_ORACLE_DRIVER_CLASS_NAME

Driver class for Flowable when using Oracle (oracle.jdbc.OracleDriver).

See the Installation Guide — Flowable Database Setup for detailed Oracle setup instructions, including the Flowable schema requirements.

3. Defining DataSource Beans

A @Configuration class defines beans for each configured data source using HikariCP. Each bean is associated with its corresponding property prefix:

Unresolved include directive in modules/ROOT/pages/database.adoc - include::../../src/main/java/com/friendly/provisionportal/config/DatabaseConfig.java[]
  • The mainDataSource bean is configured with properties under spring.datasource.default.*.

  • The flowableDataSource bean is configured with spring.datasource.flowable.* and marked with @Primary to be the default within the Flowable context.