devdb

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DevDB

type DevDB struct {
	// contains filtered or unexported fields
}

DevDB holds an ephemeral Postgres instance (via testcontainers) or a reference to an existing Postgres when a --dev-url is provided.

func Open

func Open(ctx context.Context, devURL string) (*DevDB, error)

Open returns a DevDB backed by an existing Postgres when devURL is non-empty, otherwise it starts an ephemeral container via Start.

func Start

func Start(ctx context.Context) (*DevDB, error)

Start launches an ephemeral Postgres container using testcontainers.

func (*DevDB) Apply

func (d *DevDB) Apply(ctx context.Context, sql string) error

Apply opens a fresh connection and executes the provided SQL (which may contain multiple statements).

func (*DevDB) Close

func (d *DevDB) Close() error

Close terminates the underlying container. It is a no-op when DevDB was created with an external --dev-url.

func (*DevDB) External

func (d *DevDB) External() bool

External reports whether this DevDB is backed by a caller-supplied --dev-url (true) rather than an ephemeral container (false). An external database is reused across calls and therefore must be reset between independent states.

func (*DevDB) Reset

func (d *DevDB) Reset(ctx context.Context) error

Reset drops every non-system schema and recreates a clean public schema, returning the database to a near-pristine state. It is used to isolate independent introspection states that share one external --dev-url database, where (unlike the ephemeral-container path) Close is a no-op and a fresh instance is not created per call.

func (*DevDB) URL

func (d *DevDB) URL() string

URL returns a pgx-compatible DSN for the database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL