Customized Backend Database Tables
If a database is required for the adapter, it should be completely mapped in the adapter. This prevents the creation of unnecessary tables when starting with a different profile.
The Liquibase scripts are stored in the adapter under src/resources/db/changelog/.
If many tables are required, it is advisable to store a separate databaseChangeLog file which refers to the other changelogs. This file must then be added to m8ty-domain-models/src/resources/db/changelog/db.changelog-master.xml.
In addition, the context field must be stored with the same identifier as the profile for each adapter. This prevents the tables from being created for instances on which the profile is not active. The tables should also have a prefix that clearly differentiates them from other tables in order to avoid conflicts.
Example
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.5.xsd">
<changeSet author="info@m8ty.eu" id="0001-db.mybackend.initial-1.0-account" context="mybackend">
<createSequence sequenceName="MYBACKEND_ACCOUNT_SEQ"
startValue="1000"/>
<createTable tableName="MYBACKEND_ACCOUNT" remarks="Required Mapping Data for my adapter">
<column name="ID" type="bigint">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="user_id" type="varchar(50)" remarks="UserID of Keycloak">
<constraints nullable="false"/>
</column>
<column name="version" type="bigint" defaultValueNumeric="1">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
Last modified: 02 January 2025