Documentation
¶
Index ¶
- func CheckMigrationVersion(ctx context.Context, connectionString string, expectedMigration int64) error
- type Client
- func (db *Client) Close() error
- func (db *Client) Pool() *pgxpool.Pool
- func (db *Client) TestsRawSQL(ctx context.Context, sql string, args ...any) error
- func (db *Client) TestsRawSQLQuery(ctx context.Context, sql string, processRows func(pgx.Rows) error, args ...any) error
- func (db *Client) WithTx(ctx context.Context) (*Client, pgx.Tx, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMigrationVersion ¶
func CheckMigrationVersion(ctx context.Context, connectionString string, expectedMigration int64) error
CheckMigrationVersion refuses a database older than the caller requires, or one whose River migrations are not current.
It only reads. The version comes from an explicit store rather than goose's package-level version API, for two reasons. That API's read path creates the tracking table when it is missing — a write, on exactly the unmigrated database this check exists to turn away, and one a service's own database role may not be granted. And it selects the table through a global that any goroutine may rewrite, which the race detector reports as soon as two callers overlap.
Types ¶
type Client ¶
func NewReadClient ¶
func NewReadClient(ctx context.Context, databaseURL string, options ...pool.Option) (*Client, error)
NewReadClient is NewClient for a read replica. Its pool metrics carry pool.name "read" so they stay apart from the primary's.