postgres

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ComponentType = "postgres seed"

ComponentType represents the type of the Postgres seed component.

Variables

This section is empty.

Functions

This section is empty.

Types

type SeedComponent

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

SeedComponent is a component for seeding Postgres with data.

func NewSeedComponent

func NewSeedComponent(config SeedConfig) *SeedComponent

NewSeedComponent creates a new SeedComponent instance.

func (*SeedComponent) AttachEnvironment

func (m *SeedComponent) AttachEnvironment(_ context.Context, _ *envite.Environment, writer *envite.Writer) error

func (*SeedComponent) Cleanup

func (m *SeedComponent) Cleanup(context.Context) error

func (*SeedComponent) Config

func (m *SeedComponent) Config() any

func (*SeedComponent) Prepare

func (m *SeedComponent) Prepare(context.Context) error

func (*SeedComponent) Seed

func (m *SeedComponent) Seed() error

func (*SeedComponent) Start

func (m *SeedComponent) Start(ctx context.Context) error

func (*SeedComponent) Status

func (*SeedComponent) Stop

func (*SeedComponent) Type

func (m *SeedComponent) Type() string

type SeedConfig

type SeedConfig struct {
	// ClientProvider - Provides a postgres client to use.
	// available only via code, not available in config files.
	ClientProvider func() (*sql.DB, error) `json:"-"`

	// Setup - a string that contains the SQL setup script to run before seeding the data.
	Setup string `json:"setup,omitempty"`

	// Data - a list of objects, each represents a single postgres table and its data
	Data []*SeedTableData `json:"data,omitempty"`
}

SeedConfig represents the configuration for the Postgres seed component.

type SeedTableData

type SeedTableData struct {
	// TableName - the name of the target postgres table
	TableName string `json:"table_name,omitempty"`

	// Rows - a list of rows to insert using the postgres Exec function (a `column` tag is required for each field):
	Rows []any `json:"rows,omitempty"`
}

SeedTableData represents data for a Postgres table.

Jump to

Keyboard shortcuts

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