Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package postgres registers the base snapshot importer. Purpose: detect a Postgres source. Inputs: --from-env variable name. Outputs: version and user schemas. Constraints: no DSN or passwords in errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion(source, target int) error

func Dial added in v1.4.15

func Dial(ctx context.Context, value string) (*pgx.Conn, error)

Dial opens the source connection for a URL taken from an environment variable. Errors carry fixed texts only, never the URL.

func Snapshot added in v1.4.15

func Snapshot(ctx context.Context, db *pgx.Conn, detection importer.Detection, target *config.Config, stage string, opt Options) (importer.Extracted, error)

Snapshot exports detection.Schemas from db inside one REPEATABLE READ snapshot into a portable bundle at stage. It closes db. Errors are fixed credential-free texts.

func Version added in v1.4.15

func Version(ctx context.Context, db *pgx.Conn, target *config.Config) (string, error)

Version reads the source server version and refuses a source the target cannot restore (E518). It is shared by every source that snapshots a Postgres database.

func WriteUsers added in v1.4.15

func WriteUsers(ctx context.Context, tx pgx.Tx, w *portable.Writer, m *portable.Manifest, selectSQL string) error

WriteUsers runs selectSQL (one JSON user object per row, ordered by id) inside the snapshot and writes auth/users.jsonl with each user's hash algorithm, the manifest user counts and the independent count(*) of auth.users. A hash that is not bcrypt marks the user reset-required.

Types

type Options added in v1.4.15

type Options struct {
	Source string
	InTx   func(ctx context.Context, tx pgx.Tx, w *portable.Writer, m *portable.Manifest, work string) error
	Finish func(ctx context.Context, w *portable.Writer, m *portable.Manifest) error
}

Options lets another Postgres-backed source reuse the snapshot extractor. Source names the manifest producer. InTx runs inside the snapshot transaction once the dump members are in the bundle (work holds the pg_dump outputs); it replaces the hasura-auth user export. Finish runs after the snapshot commits and before the manifest is written.

type Source

type Source struct{}

func (Source) Detect

func (Source) Extract

func (s Source) Extract(ctx context.Context, in importer.Input, stage string) (importer.Extracted, error)

func (Source) Flags

func (Source) Flags() []importer.FlagSpec

func (Source) Name

func (Source) Name() string

Jump to

Keyboard shortcuts

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