Skip to content

Add A Backend

Adding a backend should keep backend-specific behavior behind the existing seams instead of spreading switch logic through commands.

Before writing code, define:

  • Connection options such as host, port, user, account, or path.
  • Runtime context keys such as database, schema, warehouse, or role.
  • secrets references such as password env vars or key passphrase env vars.
  • Inspect capabilities that are real for the backend.
  • Statement actions that tonic should authorize and forward.

Do not fake catalog, namespace, or DDL support just to match another backend.

AreaFiles
Config modelinternal/config/config.go, internal/config/config_test.go
Backend open/summaryinternal/backend/
Target resolutioninternal/target/target.go
Connections CLIcmd/connections_add.go, cmd/connections_show.go
Query executioninternal/queryexec/
Inspect runtimeinternal/dbinspect/
CLI inspect wiringcmd/inspect_*.go
  1. Add config parsing, normalization, validation, YAML marshal/decode support, and tests.
  2. Register a backend implementation in internal/backend.
  3. Verify target resolution and secret loading.
  4. Add connections add <backend> NAME CLI support.
  5. Confirm query execution works through database/sql and backend context application.
  6. Register inspect support or explicit unsupported errors.
  7. Add real tests where practical.
  8. Update docs and the command reference.

Run realistic commands before calling a backend done:

Terminal window
go run . connections add <backend> <name> ...
go run . connections show <name>
go run . query ping --target <name>
go run . query exec --target <name> --sql 'select 1'
go run . inspect tables --target <name>
go run . query exec --file path.sql

Finish with:

Terminal window
go test ./...