Documentation
¶
Overview ¶
Package pgmigrate implements sqlmigrate.Migrator for PostgreSQL via pgx/v5.
Multi-tenant schemas ¶
Pass a Schema to target a specific PostgreSQL schema:
runner := pgmigrate.New(conn) runner.Schema = "authz"
Each schema gets its own _migrations table, so tenants are migrated independently. The sql-migrate CLI supports this via TENANT_SCHEMA; see the CLI help for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct {
Conn *pgx.Conn
Schema string // optional; qualifies the _migrations table (e.g. "authz")
}
Migrator implements sqlmigrate.Migrator using a single pgx.Conn.
func (*Migrator) Applied ¶
Applied returns all applied migrations from the _migrations table. Returns an empty slice if the table does not exist (PG error 42P01).
Note: pgx.Conn.Query is lazy — when the table is missing, the 42P01 error may surface at rows.Err() rather than at Query(). Both sites must check for it.