postgres

package
v0.0.0-...-d56b225 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package postgres provides embedded PostgreSQL functionality for production use. This package is used by the plan command to create temporary PostgreSQL instances for validating desired state schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddedPostgres

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

EmbeddedPostgres manages a temporary embedded PostgreSQL instance. This is used by the plan command to validate desired state schemas.

func StartEmbeddedPostgres

func StartEmbeddedPostgres(config *EmbeddedPostgresConfig) (*EmbeddedPostgres, error)

StartEmbeddedPostgres starts a temporary embedded PostgreSQL instance

func (*EmbeddedPostgres) ApplySchema

func (ep *EmbeddedPostgres) ApplySchema(ctx context.Context, schema string, sql string) error

ApplySchema resets a schema (drops and recreates it) and applies SQL to it. This ensures a clean state before applying the desired schema definition.

func (*EmbeddedPostgres) GetConnectionDetails

func (ep *EmbeddedPostgres) GetConnectionDetails() (host string, port int, database, username, password string)

GetConnectionDetails returns all connection details needed to connect to the embedded PostgreSQL instance

func (*EmbeddedPostgres) Stop

func (ep *EmbeddedPostgres) Stop() error

Stop stops and cleans up the embedded PostgreSQL instance

type EmbeddedPostgresConfig

type EmbeddedPostgresConfig struct {
	Version  PostgresVersion
	Database string
	Username string
	Password string
}

EmbeddedPostgresConfig holds configuration for starting embedded PostgreSQL

type PostgresVersion

type PostgresVersion = embeddedpostgres.PostgresVersion

PostgresVersion is an alias for the embedded-postgres version type.

func DetectPostgresVersionFromDB

func DetectPostgresVersionFromDB(host string, port int, database, user, password string) (PostgresVersion, error)

DetectPostgresVersionFromDB connects to a database and detects its version This is a convenience function that opens a connection, detects the version, and closes it

Jump to

Keyboard shortcuts

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