Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR sets up a PostgreSQL database for the Queensac service. The key changes include:
- Adding database initialization and pool creation in main.rs.
- Introducing a new db module with functions for creating the pool and initializing the database.
- Adding a new migration file and updating Cargo.toml and .env for PostgreSQL support.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rook/src/main.rs | Integrates database pool creation, dotenv usage, and updates app() to accept state. |
| rook/src/lib.rs | Exports the new db module. |
| rook/src/db.rs | Implements create_pool, init_db, and adds a test for database connection. |
| rook/migrations/202450527173623_initial.sql | Provides initial SQL migration for subscribers table. |
| rook/Cargo.toml | Adds required dependencies for sqlx and dotenv. |
| rook/.env | Defines the DATABASE_URL for local PostgreSQL connection. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
?? Blunder 😵💫 ❌ Failure DetailsSee the full battle logs here: View Logs Time to rethink your next move! |
|
?? Blunder 😵💫 ❌ Failure DetailsSee the full battle logs here: View Logs Time to rethink your next move! |
There was a problem hiding this comment.
Pull Request Overview
This PR sets up a PostgreSQL-backed database using SQLx migrations and integrates connection pooling into the Axum application.
- Introduce a
dbmodule withcreate_poolandinit_dbfunctions and a basic connectivity test - Update
main.rsto load environment variables, create the pool, run migrations, and pass the pool into the router state - Add initial SQL migration, required dependencies (
sqlx,dotenv), a.envfile, and configure GitHub Actions to spin up Postgres for tests
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rook/src/main.rs | Load DATABASE_URL, create SQLx pool, run migrations, and pass pool via with_state |
| rook/src/lib.rs | Expose new db module in crate root |
| rook/src/db.rs | Implement create_pool, init_db, and a connectivity test |
| rook/migrations/202450527173623_initial.sql | Define subscribers table schema |
| rook/Cargo.toml | Add sqlx and dotenv dependencies |
| rook/.env | Provide local DATABASE_URL (committed) |
| .github/workflows/rust.yml | Add Postgres service and set DATABASE_URL for CI tests |
Comments suppressed due to low confidence (2)
rook/src/db.rs:13
- The
init_dbfunction isn’t covered by existing tests. Add a test that callsinit_dband verifies that thesubscriberstable exists after migrations run.
pub async fn init_db(pool: &PgPool) -> Result<(), sqlx::Error> {
rook/.env:1
- Committing a
.envfile with real database credentials can expose sensitive information. Consider removing it from version control, adding.envto.gitignore, and including a.env.exampleinstead.
DATABASE_URL=postgres://postgres:password@localhost:5432/queensac
|
코파일럿 아깐 별말 없더니 이제는 좀 치네 |
|
아 add suggenstion to batch 누르면 코파일럿 리뷰 한번에 커밋 날릴 수 있구나,,, 몰랐네 |
|
?? Blunder 😵💫 ❌ Failure DetailsSee the full battle logs here: View Logs Time to rethink your next move! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
꺄오 성공이다 |
|
참고로 현재 배포를 위해 사용하고 있는 shuttle 에서도 db 설정에 관한 구현을 제공한다 참고 하지만 이걸 사용하지 않은 이유는 몇주 사용해보았는데, 계속해서 shuttle을 사용하기엔 너무 작은 것 같다. 좀만 돌리면 곰방 뻗어버리는데 물론 이건 요금제 때문이기는 하다. 하지만 돈내고 사용할거면 AWS를 사용하여 더 커스터마이징 할 수 있는 서버리스 서비스를 사용하는게 좋아보인다. shuttle은 서버 한대를 빌린다기보단 그냥 프로젝트 실행시킬 프로세스 하나를 빌리는 느낌이다. 그래서 서버에 접속하여 설정하는 것이 불가능하다. 언젠간 shuttle을 걷어낼 거라 shuttle을 사용하여 db를 구축하진 않았다. |
♟️ What’s this PR about?
PostgreSQL을 사용한 DB를 구축하였습니다.
알아두면 좋을 명령어.
컴파일 타임에 확인할 수 있도록 해주는 명령어.
migrates 디렉터리 안에 있는 sql 문의 변경및실행을 추적하고 새로 변경되었다면 sql 파일 실행
🔗 Related Issues / PRs
close: #80