Documentation
¶
Index ¶
- func ConnectDB(connString string) (*pgxpool.Pool, error)
- func ConnectDBWithMaxConns(connString string, maxConns int32) (*pgxpool.Pool, error)
- func DBVersion(ctx context.Context, pool *pgxpool.Pool) (int64, error)
- func DownTo(ctx context.Context, connString string, version int64) error
- func ExpectedVersion() (int64, error)
- func IsSchemaCurrent(ctx context.Context, pool *pgxpool.Pool) (bool, error)
- func MigrationStatus(ctx context.Context, connString string) ([]*goose.MigrationStatus, error)
- func RegisterTypeLoader(loader func(context.Context, *pgx.Conn) error)
- func RunMigrations(connString string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectDBWithMaxConns ¶
ConnectDBWithMaxConns creates a pool with a custom maximum connection count. Use when the caller needs higher concurrency than the default (e.g. the seeder).
func DBVersion ¶
DBVersion returns the current schema version recorded in goose_db_version, or 0 if that table doesn't exist yet (a database that has never been migrated).
func DownTo ¶
DownTo migrates the database down to the given version, session-locked like RunMigrations. This is destructive (it runs migrations' Down scripts, which commonly drop data/columns/tables) - callers are expected to gate it behind an explicit operator opt-in (see cmd/admin-tools's `migrate down-to`), not call it unconditionally.
func ExpectedVersion ¶
ExpectedVersion returns the highest migration version embedded in this binary, derived from the numeric prefix of migrations/*.sql filenames (goose's own versioning scheme). This is what the binary expects the schema to be at once fully migrated.
func IsSchemaCurrent ¶
IsSchemaCurrent reports whether the database schema is at least as new as what this binary expects. This intentionally checks >=, not ==: during a rolling upgrade the DB can be ahead of an older binary instance still finishing its rollout, and that instance must stay Ready rather than start failing readiness against a schema version it merely doesn't know about.
func MigrationStatus ¶
MigrationStatus returns the applied/pending state of every migration known to this binary.
func RegisterTypeLoader ¶
RegisterTypeLoader registers a function to load custom PostgreSQL types on each new connection. This function is safe to call from init() functions across different packages.
func RunMigrations ¶
RunMigrations applies all pending migrations to the database at connString.
Types ¶
This section is empty.