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 ¶
- func CheckVersion(source, target int) error
- func Dial(ctx context.Context, value string) (*pgx.Conn, error)
- func Snapshot(ctx context.Context, db *pgx.Conn, detection importer.Detection, ...) (importer.Extracted, error)
- func Version(ctx context.Context, db *pgx.Conn, target *config.Config) (string, error)
- func WriteUsers(ctx context.Context, tx pgx.Tx, w *portable.Writer, m *portable.Manifest, ...) error
- type Options
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckVersion ¶
func Dial ¶ added in v1.4.15
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
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.