Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: switch driver to pgx5 #3258

Merged
merged 13 commits into from
Sep 5, 2023
Merged

db: switch driver to pgx5 #3258

merged 13 commits into from
Sep 5, 2023

Conversation

mastercactapus
Copy link
Member

@mastercactapus mastercactapus commented Sep 1, 2023

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 using sql.DB in a few places. Here are some insights into why certain choices were made:

  • pgxpool.Pool is a native PGX type, while sql.DB is from the Go standard library.
  • The swomsg package was previously using sql.DB and converting it into a pgx connection and back again, adding unnecessary boilerplate. This has been streamlined by directly using pgxpool.Pool.
  • The pgxpool was used directly where possible elsewhere in the swo code to eliminate boilerplate code.
  • The old AcquireConn method, which allowed fetching a PGX-native connection object from a sql.DB, has been removed in pgx v5, further justifying the use of pgxpool.Pool where possible.

The GoAlert application code continues to use Go's standard library interfaces (sql.DB), while the swo components have been upgraded to use the native PGX interfaces (pgxpool.Pool).

@github-actions github-actions bot added the size/m label Sep 1, 2023
@mastercactapus mastercactapus merged commit 0cd7d32 into master Sep 5, 2023
@mastercactapus mastercactapus deleted the pgx5-swo branch September 5, 2023 18:22
1ddo pushed a commit to 1ddo/goalert that referenced this pull request Sep 7, 2023
* update swo sqlc output to pgx v5

* update swosync to v5

* update swoinfo to use v5

* update swomsg to use pgxpool (v5)

* update harness to use v5

* update app to use v5

* formatting

* swo to v5

* ensure connections are closed

* run tidy

* leave formatting to separate PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants