Documentation
¶
Overview ¶
Package postgres connects to PostgreSQL and applies namespaced migrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSchemaNotReady = errors.New("postgres: the database schema is not ready")
ErrSchemaNotReady means the database lacks migrations this binary needs.
Functions ¶
func Migrate ¶
Migrate applies the pending migrations of each set, in the order given. Each file runs in its own transaction, and one advisory lock serialises concurrent runs. A database that is ahead of this binary is reported and left alone.
func Open ¶
Open connects to PostgreSQL and checks the connection.
For a host that is not a Unix socket or loopback address, Open requires verified TLS (sslmode=verify-full, with the system's trusted roots unless sslrootcert is set) when neither the URL nor PGSSLMODE chooses a mode. An explicit weaker mode is respected, with a warning.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker reports whether a database has every migration this binary needs. Newer migrations from a later release are tolerated, so older replicas keep serving during a rolling upgrade. Once satisfied, it stops querying: schemas only grow.
type Set ¶
Set is one namespace's migrations: files named NNN_name.sql at the root of Files. Other files, such as a README, are ignored.