7.5. Database schema initialization
When you are using SonataFlow with PostgreSQL persistence, you can initialize the database schema either by enabling Flyway or by manually applying database schema updates using Data Definition Language (DDL) scripts.
Flyway is managed by the kie-addons-quarkus-flyway runtime module and it is disabled by default. To enable Flyway, you must configure it using one of the following methods:
7.5.1. Flyway configuration in the workflow ConfigMap 링크 복사링크가 클립보드에 복사되었습니다!
To enable Flyway in the workflow ConfigMap, you can add the following property:
Example of enabling Flyway in the workflow ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: example-workflow
name: example-workflow-props
data:
application.properties: |
kie.flyway.enabled = true
7.5.2. Flyway configuration using environment variables in the workflow container 링크 복사링크가 클립보드에 복사되었습니다!
You can enable Flyway by adding an environment variable to the spec.podTemplate.container field in the SonataFlow CR by using the following example:
Example of enabling Flyway by using the workflow container environment variable
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
name: example-workflow
annotations:
sonataflow.org/description: Example Workflow
sonataflow.org/version: 0.0.1
spec:
podTemplate:
container:
env:
- name: KIE_FLYWAY_ENABLED
value: 'true'
flow: ...
7.5.3. Flyway configuration using SonataFlowPlatform properties 링크 복사링크가 클립보드에 복사되었습니다!
To apply a common Flyway configuration to all workflows within a namespace, you can add the property to the spec.properties.flow field of the SonataFlowPlatform CR shown in the following example:
This configuration is applied during workflow deployment. Ensure the Flyway property is set before deploying workflows.
Example of enabling Flyway by using the SonataFlowPlatform properties
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
name: sonataflow-platform
spec:
properties:
flow:
- name: kie.flyway.enabled
value: true
7.5.4. Initializing a manual database using DDL scripts 링크 복사링크가 클립보드에 복사되었습니다!
If you prefer manual initialization, you must disable Flyway by ensuring the kie.flyway.enabled property is either not configured or explicitly set to false.
- By default, each workflow uses a schema name equal to the workflow name. Ensure that you manually apply the schema initialization for each workflow.
-
If you are using the
SonataFlowcustom resource (CR) persistence configuration, you can specify a custom schema name.
Procedure
- Download the DDL scripts from the kogito-ddl-9.103.0.redhat-00003-db-scripts.zip location.
- Extract the files.
Run the
.sqlfiles located in the root directory on the target PostgreSQL database. Ensure that the files are executed in the order of their version numbers.For example:
-
V1.35.0__create_runtime_PostgreSQL.sql -
V10.0.0__add_business_key_PostgreSQL.sql V10.0.1__alter_correlation_PostgreSQL.sql참고The file version numbers are not associated with the OpenShift Serverless Logic Operator versioning.
-