Starting with version 3.0.0 of tia contentserver coreCore Content Server, the database (both protocol and metadata) is managed by flywayFlyway. Flyway is a framework that allows the management of databases using scripts and records the used ones. This allows applications to self-manage the database even when changing structure, migrating data or performing complex sql SQL-based operations.
In contrast to using JPA (Java/Jakarta Persistence API) to manage the database, flyway needs sql using Flyway requires SQL scripts for each database supported. By default we currently provide tia Core ships with scripts for H2, MSSQL server and Oracle.
...
The database migrations are done using sql SQL-scripts which are applied and the usage is recorded in a flyway Flyway history table in the database. Upon each start, the history table is compared to the existing scripts and if scripts are missing, the migrations will be applied.
...
Version migrations have the pattern V<Version>__<description>.sql
. The capital letter V is important, lowercase will not be recognized. The version can either be in the from 2_9_7
or 2.9.7
both are identical for flywayFlyway. The description can be any text, spaces must be replaced by lowercase stash and should not be too long. Those migrations are executed in the versioning order. Any already applied file must not be changed.
...
The database services are managed for each repository, therefor therefore each database-based service in the repository.cfg has an optional parameter scripts
. The default value is classpath:sql/[meta|metav2|prot]/migration/[h2|sqlserver|oracle]
depending on the service and the database vendor.
...
In the case additional scripts are required, the scripts
parameter can be used to provide them. For example for the oracle version of
This example configures the protocol service additional scripts for oracle in the location /data/custom/kgs/protocol.:
Code Block |
---|
<repo>.protocolservice.database.scripts=classpath:sql/prot/migration/oracle,filesystem:/data/custom/kgs/protocol |
...
In case a database vendor not supported by default is needed, the scripts parameter can also be used. In addition to the JDBC-Driver some vendors also require an additional flyway Flyway dependency (e.g. mysql). The list of supported databases can be found here: https://documentation.red-gate.com/fd/supported-databases-184127454.html .
For example, using a custom vendor for metasaervice metaservice database v2, and the scripts are located in /kgs/data/sql/vendor
...
The jar files for both the driver and the flyway dependency can then be placed in a lib folder, say /kgs/lib, and must then be added to the application, depending on the deployment, using the parameter loader.path, e.g. for container deployments LOADER_PATH=/kgs/lib
.