feat(db): migrate database service from Neon to Docker Postgres - #5
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughMigrates DB from Neon to local Docker Postgres: replaces Neon client with Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application (drizzle)
participant Pool as pg.Pool
participant DB as Postgres (docker-compose)
App->>Pool: createDb() -> new Pool(connectionString)
Note right of Pool: pool handles connections\nand emits 'error' events
App->>Pool: drizzle queries via client
Pool->>DB: TCP connection / SQL commands
DB-->>Pool: query results
Pool-->>App: results returned to drizzle
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docker-compose.yml`:
- Line 5: Replace the floating image tag to pin Postgres to a stable major
version; update the docker-compose service line that currently reads "image:
postgres" to a specific tag like "postgres:16" (or a variant such as
"postgres:16-bookworm" or "postgres:16-alpine") so the service uses a
reproducible Postgres major version instead of the floating "postgres" tag.
In `@package.json`:
- Line 15: The npm script "db:start" currently runs "docker compose up -d" which
can return before Postgres is healthy; update the "db:start" script to include
the "--wait" flag so docker compose blocks until services with healthchecks
(your Postgres) are healthy before returning, i.e., modify the db:start command
string to add --wait to ensure downstream tasks like db:push don't race with an
unready DB.
In `@src/db/index.ts`:
- Around line 8-12: Attach an 'error' listener to the created Pool instance to
catch idle-client errors so they don't bubble to Node and crash the process:
after const pool = new Pool(...) add pool.on('error', (err) => { /* log the
error and handle gracefully (e.g., console.error or your logger) without
rethrowing */ }); keep returning drizzle({ client: pool, schema }) as-is so the
pool is used with the new listener.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2e8c720f-8784-4541-a7d3-2ea3891bee2d
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
.env.exampledocker-compose.ymlpackage.jsonsrc/db/index.ts
Summary
pgPool +drizzle-orm/node-postgres@neondatabase/serverless, addpgand@types/pgdocker-compose.ymlfor local Postgres servicepackage.json(db:start,db:watch,db:stop,db:down).env.examplefor local Postgres URLValidation
bun run db:push(success)bun run db:startmay fail if host port5432is already in useCloses #4
Summary by CodeRabbit
New Features
Chores