Skip to content

Database Vendors

IAM owns its schema via its own dedicated Flyway instance — history table iam_flyway_history, never your flyway_schema_history — and partitions migrations by vendor (one consolidated V1 per vendor since 2.0.0):

db/iam/migration/
├── postgresql/ V1__create_iam_schema.sql (default)
└── mysql/ V1__create_iam_schema.sql

The active set is selected by one property: iam.database.vendor resolves classpath:db/iam/migration/<vendor>. Your spring.flyway.* configuration is never read or modified by IAM — hosts with their own migrations keep vanilla Spring Boot defaults. To take over IAM’s schema management entirely, set iam.database.migrations-enabled: false.

Nothing to configure beyond your datasource:

spring:
datasource:
url: jdbc:postgresql://localhost:5432/myapp
runtimeOnly("org.postgresql:postgresql")
runtimeOnly("org.flywaydb:flyway-core")
runtimeOnly("org.flywaydb:flyway-database-postgresql")

Uses native UUID, JSONB, and TIMESTAMP types.

iam:
database:
vendor: mysql
spring:
datasource:
url: jdbc:mysql://localhost:3306/myapp
runtimeOnly("com.mysql:mysql-connector-j")
runtimeOnly("org.flywaydb:flyway-core")
runtimeOnly("org.flywaydb:flyway-mysql")

Requires MySQL 8.0.13+ (expression defaults, functional indexes). The MySQL schema maps types deliberately:

PostgreSQL MySQL Why
UUID BINARY(16) Hibernate 6’s default UUID mapping on MySQL
JSONB JSON native JSON on both
TEXT[] JSON array MySQL has no arrays; entities map List<String> as JSON on every vendor
TIMESTAMP DATETIME(6) no 2038 limit, no TIMESTAMP auto-init quirk
gen_random_uuid() default (UUID_TO_BIN(UUID())) expression defaults

The entity mappings are vendor-neutral (@JdbcTypeCode(SqlTypes.JSON), no hardcoded dialect), and the schema is verified on every boot by ddl-auto: validate — a green start is the parity check. The repository ships a MySQL Testcontainers parity suite covering migrations, JSON/array round-trips, and end-to-end permission resolution.

Do not set hibernate.dialect yourself — Hibernate 6 auto-detects the right dialect from JDBC metadata. A pinned PostgreSQL dialect against MySQL fails at boot with sequence-discovery errors.

  1. Author db/iam/migration/<vendor>/V1__create_iam_schema.sql translating the DDL (mind: UUID storage, JSON type, timestamp semantics, upsert syntax).
  2. Set iam.database.vendor: <vendor> and add the driver + Flyway support module.
  3. Boot with ddl-auto: validate against a real instance — validation failures are your parity TODO list, one column at a time.