pg

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default port for postgres
	DefaultPort = 15432
	// DefaultUser is the default user for postgres
	DefaultUser = "postgres"
	// DefaultPass is the default password for postgres
	DefaultPass = "postgres"
	// DefaultName is the default database name for postgres
	DefaultName = "postgres"
	// DefaultTemplate is the default template name for postgres when creating a new database with migtations and fixtures
	DefaultTemplate = "dbctl_template"
)

Variables

This section is empty.

Functions

func ApplyFixtures

func ApplyFixtures(ctx context.Context, conn *sql.DB, fixtureFiles []string, uri string) error

ApplyFixtures applies fixtures on a postgres database

func Instances

func Instances(ctx context.Context) ([]database.Info, error)

Instances returns a list of postgres instances

func RunMigrations

func RunMigrations(ctx context.Context, conn *sql.DB, migrationsFiles []string, uri string) error

RunMigrations runs migrations on a postgres database

Types

type Option

type Option func(*config) error

Option is the type of the functional options for the postgres

func WithFixtures

func WithFixtures(path string) Option

WithFixtures applied selected fixtures to config

func WithHost

func WithHost(user, pass, name string, port uint32) Option

WithHost applied selected postgres host to config

func WithLabel added in v0.4.8

func WithLabel(label string) Option

WithLabel applied selected label to config

func WithLogger

func WithLogger(logger io.Writer) Option

WithLogger applied selected logger to config

func WithMigrations

func WithMigrations(path string) Option

WithMigrations applied selected migrations to config

func WithUI added in v0.3.2

func WithUI(withIU bool) Option

WithUI applied withUI option to config

func WithVersion

func WithVersion(version string) Option

WithVersion applied selected postgres version to config

type Postgres

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

Postgres is a postgres database instance

func New

func New(options ...Option) (*Postgres, error)

New creates a new postgres database instance controller

func (*Postgres) ContainerID added in v0.5.0

func (p *Postgres) ContainerID() string

func (*Postgres) CreateDB added in v0.4.0

CreateDB creates a new database with given migrations and fixtures

func (*Postgres) RemoveDB added in v0.4.0

func (p *Postgres) RemoveDB(ctx context.Context, uri string) error

RemoveDB removes a database from postgres by given uri

func (*Postgres) Start

func (p *Postgres) Start(ctx context.Context, detach bool) error

Start starts a postgres database

func (*Postgres) Stop

func (p *Postgres) Stop(ctx context.Context) error

Stop stops a postgres database

func (*Postgres) URI

func (p *Postgres) URI() string

URI returns the postgres connection uri

func (*Postgres) WaitForStart

func (p *Postgres) WaitForStart(ctx context.Context, timeout time.Duration) error

WaitForStart waits for postgres to start

Jump to

Keyboard shortcuts

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