db: switch driver to pgx5 #3258
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Updates the rest of the application to use pgx v5 from v4.
Out of Scope:
Migrating from
github.com/jackc/pgtype
->github.com/jackc/pgx/v5/pgtype
will be done in a separate PR.Technical Details:
During the migration, we encountered the question of whether to use
pgxpool.Pool
or continue usingsql.DB
in a few places. Here are some insights into why certain choices were made:pgxpool.Pool
is a native PGX type, whilesql.DB
is from the Go standard library.swomsg
package was previously usingsql.DB
and converting it into apgx
connection and back again, adding unnecessary boilerplate. This has been streamlined by directly usingpgxpool.Pool
.pgxpool
was used directly where possible elsewhere in theswo
code to eliminate boilerplate code.AcquireConn
method, which allowed fetching a PGX-native connection object from asql.DB
, has been removed inpgx v5
, further justifying the use ofpgxpool.Pool
where possible.The GoAlert application code continues to use Go's standard library interfaces (
sql.DB
), while theswo
components have been upgraded to use the native PGX interfaces (pgxpool.Pool
).