feat(db): wire pgx pool with sqlc and Atlas tooling #157
Draft
yiningsoong wants to merge 6 commits into
Draft
Conversation
3d8a427 to
c585715
Compare
YimingIsCOLD
reviewed
May 6, 2026
| @@ -0,0 +1,14 @@ | |||
| services: | |||
| postgres: | |||
| image: postgres:17 | |||
Contributor
There was a problem hiding this comment.
Can we check if AWS supports Postgres version 18? IIRC, v18 has built in UUIDv7 function.
|
|
||
| func run(ctx context.Context, cfg *config.Config) error { | ||
| h, err := handler.New(cfg) | ||
| pool, err := pgxpool.New(ctx, cfg.DatabaseURL) |
Contributor
There was a problem hiding this comment.
Question: Since we don't have any queries yet, can we defer the initialisation of pgx until we have our first query?
| services: | ||
| postgres: | ||
| image: postgres:17 | ||
| environment: |
Contributor
There was a problem hiding this comment.
Shall we add container_name: tw-postgres above environment?
| environment: | ||
| POSTGRES_USER: user | ||
| POSTGRES_PASSWORD: pass | ||
| POSTGRES_DB: teacher_workspace |
Contributor
There was a problem hiding this comment.
Suggested change
| POSTGRES_DB: teacher_workspace | |
| POSTGRES_DB: tw OR tw-dev |
|
|
||
| ```bash | ||
| # sqlc: generates Go code from SQL queries | ||
| go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest |
Contributor
There was a problem hiding this comment.
Can explore go tool to setup sqlc and atlas. I think we can pin the tools to specific version and contributors no need to manually install tools.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚀 Summary
Wire pgx/v5 into the server as the PostgreSQL driver, with sqlc and Atlas configured for type-safe queries and schema migrations. The pool is initialised in run() at startup,
pinged to fail fast on an unreachable database, and injected into the handler. No queries or schema tables are added yet — this is purely the wiring and tooling foundation.
✏️ Changes