Developer Guide / Database & Migrations

Database & Migrations

Schema-per-service PostgreSQL with Flyway.

The platform uses a single PostgreSQL instance (database portal), but each microservice owns its own schema rather than using public. Schema changes are managed with Flyway migrations that run automatically on service start.

Schemas

SchemaServiceKey tables
authauth-serviceportal_user, portal_role, portal_user_role
pagepage-serviceportal_page, portal_site
assetasset-serviceportal_asset
webcontentweb-content-serviceportal_web_content
portletportlet-serviceportal_portlet
soapsoap-tracker-serviceportal_soap_log
emailtemplateemail-template-serviceemail_template
emailemail-serviceemail_template, email_variable_mapping, email_send_log
settingssettings-servicesite_configuration, ssl_configuration, cluster_node, email_configuration, sms_configuration, auth_provider
i
Conventions: primary keys are BIGSERIAL; created_at/updated_at are TIMESTAMPTZ DEFAULT NOW(); multilingual columns are stored as JSON; tables are schema-qualified (e.g. auth.portal_user).

Connection

Inside Docker the host is postgres:5432; from the host it is localhost:54322. Default dev credentials: database portal, user portal_user. The seeded admin is admin / admin@portal.com with ROLE_ADMIN + ROLE_USER. Browse with pgAdmin at localhost:5050.

Migrations

Migration scripts live under each module at src/main/resources/db/migration/V*.sql and are applied in version order.

<module>/src/main/resources/db/migration/V1__init.sql
<module>/src/main/resources/db/migration/V2__add_table.sql
!
Never edit a migration that has already been applied. Add a new V<next>__*.sql file instead — changing applied migrations breaks Flyway's checksums.

Browsing the database

In Docker, pgAdmin is available on port 5050 for inspecting schemas and data during development.

Inspecting service schemas in pgAdmin.
Inspecting service schemas in pgAdmin.