Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Starting with version 3.0.0 of tia contentserver core, the database (both protocol and metadata) are is managed by flyway. 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 complex sql based operations.

...

The database migrations are done using sql scripts which are applied and the usage is recorded in a 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.

We are can use two types of files: versioned migrations and repeatable migrations.

Version migrations have the pattern V<Version>__<description>.sql. The capital letter V is importedimportant, lowercase will not be recognisedrecognized. The version can either be in the from 2_9_7 or 2.9.7 both are identical for flyway. 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.

Repeatable migrations have the pattern R__<description>.sql. Both the capital letter R and the restrictions for the description apply as for the versioned migrations. The repeatable migrations are executed after all versioned migrations are applied. In contrast to versioned, the repeatable migrations can be changed once applied. Every time the content changes, the files are re-executed. Those migrations can be used for example, when the filling of a field changes and the existing values need to be adapted to the new value.

...

Customizing

The database services are managed for each repository, therefor 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.

...

Note

When adding custom support for a database vendor, before each update it is required to check if the there are changes required which need to be added to those scripts.

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 dependency (e.g. mysql). The list of supported databases can be found here: https://documentation.red-gate.com/fd/supported-databases-184127454.html .

...

Code Block
<repo>.metaservice.databasev2.scripts=filesystem:/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.