Database Configuration

Firmiana uses an embedded H2 database with Flyway for schema management.

Datasource Configuration

datasources:
  default:
    url: jdbc:h2:./data/matrix;DB_CLOSE_DELAY=-1
    driver-class-name: org.h2.Driver
    username: sa
    password: ""
    schema-generate: NONE
    dialect: H2

Environment Variable Overrides

VariableDefaultDescription
DB_URLjdbc:h2:./data/matrix;DB_CLOSE_DELAY=-1JDBC URL
DB_USERNAMEsaDatabase username
DB_PASSWORD(empty)Database password

H2 Modes

File Mode (Production Default)

h2:
  mode: file
  path: ./data/matrix

Data persists to ./data/matrix.mv.db. The DB_CLOSE_DELAY=-1 parameter keeps the database open while the JVM runs.

In-Memory Mode (Testing)

h2:
  mode: mem

Or override the datasource URL:

jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1

Data is lost when the JVM stops. Used in test classes with @Property(name = "datasources.default.url", value = "jdbc:h2:mem:testdb").

Connection Pool

HikariCP manages the connection pool:

PropertyDefaultDescription
h2.pool-size10Maximum connections
h2.max-lifetime1800000Max connection lifetime (ms)

H2 Web Console

The H2 web console is disabled by default:

h2:
  web-console: false
  web-console-port: 8082

Enable for development:

h2:
  web-console: true

Access at http://localhost:8082 with JDBC URL jdbc:h2:./data/matrix.

Legacy Schema Initializer

H2SchemaInitializer contains the full DDL but is disabled by default:

h2:
  schema-initializer:
    enabled: false  # Use Flyway instead

It exists for reference and backward compatibility. Always prefer Flyway migrations.

Data Directory

The database file lives under ./data/matrix (gitignored). Stale local state can affect manual tests. To reset:

rm -rf data/matrix*
Warning

Deleting the database file removes all data. Back up before resetting.