Skip to content

Support structured database connection config as alternative to URL #39

@mikkeldamsgaard

Description

@mikkeldamsgaard

Summary

The seed spec currently requires database connections to be specified as a single url: string. This forces users to deal with URL encoding of credentials and makes seed specs harder to read. A structured config format would eliminate this class of issues entirely.

Problem

Building a connection URL in a template is fragile:

database:
  driver: postgres
  url: "postgres://user:{{ env.DB_PASSWORD }}@host:5432/mydb?sslmode=disable"

If the password contains URL-reserved characters (@, %, :, etc.), the URL breaks. Users must either:

Both are workarounds for a problem that shouldn't exist — the user just wants to provide connection parameters.

Suggested Enhancement

Accept discrete connection fields as an alternative to url::

database:
  driver: postgres
  host: pg.example.com
  port: 5432
  user: netbird
  password: "{{ env.DB_PASSWORD }}"
  name: mydb
  options:
    sslmode: disable

Initium would construct the connection internally using the driver's native API (e.g., PgConnectOptions for PostgreSQL, MySqlConnectOptions for MySQL), bypassing URL parsing entirely. The url: field would remain supported for backward compatibility.

Benefits

  • No encoding issues — passwords with any characters just work
  • Readable — mirrors how Kubernetes operators and Helm charts typically express DB config
  • Type-safe — invalid field names caught at parse time instead of silently producing a bad URL
  • Driver-agnostic — Initium maps fields to whatever the driver needs; users don't need to know URL format differences between PostgreSQL and MySQL

Use Case

We hit this in the netbird Helm chart (issue #32). Our workaround is PostgreSQL key-value DSN + a chain of MiniJinja replace filters for MySQL. A structured config would let us drop both workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions