Documentation
¶
Overview ¶
Package postgres implements the owned PostgreSQL ledger and lock backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidConfig indicates unusable PostgreSQL backend configuration. ErrInvalidConfig = errors.New("invalid PostgreSQL migration configuration") // ErrLockNotHeld indicates that advisory ownership was lost or duplicated. ErrLockNotHeld = errors.New("PostgreSQL migration advisory lock not held") // ErrSessionReleased indicates use after lock-session release. ErrSessionReleased = errors.New("PostgreSQL migration session released") // ErrLedgerConflict indicates that owned-ledger state changed unexpectedly. ErrLedgerConflict = errors.New("PostgreSQL migration ledger conflict") )
var ErrInvalidSchemaSnapshot = errors.New("invalid PostgreSQL schema snapshot")
ErrInvalidSchemaSnapshot indicates ambiguous catalog data that cannot form a reviewed baseline contract.
Functions ¶
func Fingerprint ¶
func Fingerprint(objects []SchemaObject) (migrations.Checksum, error)
Fingerprint hashes a complete, unambiguous PostgreSQL schema snapshot.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend owns PostgreSQL preparation and creates connection-bound sessions.
func (*Backend) Acquire ¶
Acquire waits for the stable package advisory lock on one physical connection and returns all subsequent operations bound to that connection.
func (*Backend) Inspect ¶
Inspect returns the current schema fingerprint for review and baseline contract generation. It does not mutate either migration ledger.
func (*Backend) InspectObjects ¶
func (backend *Backend) InspectObjects(ctx context.Context) ([]SchemaObject, error)
InspectObjects returns the canonical catalog objects used for review and fingerprint diagnostics. The package-owned ledger is excluded.
type Option ¶
Option configures a PostgreSQL backend.
func WithLockRetryInterval ¶
WithLockRetryInterval controls polling when another job owns the advisory lock. Cancellation is always honored while waiting.
func WithLockTimeout ¶
WithLockTimeout bounds advisory-lock polling independently of the caller's broader job deadline. Lock attempts repeat only while another session owns the lock; database errors are returned without retry.
func WithStatementTimeout ¶
WithStatementTimeout applies PostgreSQL statement_timeout to each migration transaction or explicit no-transaction execution session.
type SchemaObject ¶
SchemaObject is one canonical PostgreSQL catalog identity and definition. Objects are sorted during fingerprinting, so database row order is irrelevant.