NODE_ENV, projectName, and SONAMU_DB_* environment
variables. The old database.name and database.environments fields are no longer supported.
Basic Structure
database
Specifies the PostgreSQL driver. Type:"pg" | "pgnative" (optional)
Default: "pg"
"pg": Pure JavaScript PostgreSQL driver. Recommended for most projects."pgnative": Native driver using C bindings. Use only when you need it and can support the platform requirements.
defaultOptions
Knex options shared by every generated preset.SONAMU_DB_*. Use defaultOptions.connection only for
connection options shared by every environment, such as SSL settings. Sonamu keeps host, port,
user, password, and database values scoped to the environment that loaded them.
Dotenv Loading
Before importingsonamu.config.ts, Sonamu applies dotenv sources for the current environment:
.env.env.${NODE_ENV}.env.local- Exported process environment variables
NODE_ENV values are test, development, staging, and production. If NODE_ENV is
missing, Sonamu uses development.
Database Variables
- Use
SONAMU_DB_NAMEwhen present. - Otherwise generate
${projectName}_${environment}. - Use
${projectName}_fixturefor the fixture database.
Presets
Sonamu generates these presets:DB.getDB("w") resolves to the current environment’s main preset. DB.getDB("r") resolves to the
current environment’s read-only preset.
Read-Only Replicas
UseSONAMU_DB_READONLY_* variables for read-only replicas. Any missing read-only field uses the
current environment’s main connection value.
.env.production
Fixture DB
Fixture DB settings use theSONAMU_DB_FIXTURE_* prefix.
.env.test
SONAMU_DB_* values from the test environment.
Removed Fields
These fields are no longer supported:.env, .env.development, .env.staging, .env.production, and
.env.test using SONAMU_DB_*, SONAMU_DB_READONLY_*, and SONAMU_DB_FIXTURE_*.