Automate db:migrate on merge#11
Conversation
Co-authored-by: andre.timo.landgraf <andre.timo.landgraf@gmail.com>
|
Cursor Agent can help with this pull request. Just |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a new GitHub Actions workflow to run Drizzle migrations on pushes to main when schema or migration files change, setting DATABASE_URL from secrets, installing dependencies with Bun, and executing bun run db:migrate in the app directory. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub
participant WF as Actions Runner (ubuntu-latest)
rect rgb(245,245,255)
Dev->>GH: Push to main
GH-->>GH: Path filter (schema.ts or migrations/**)
GH-->>WF: Trigger "Run Drizzle migrations" workflow
end
rect rgb(240,255,240)
WF->>WF: Checkout repository
WF->>WF: Setup Bun (latest)
WF->>WF: bun install (working-dir: app/)
note right of WF: Env: DATABASE_URL from secrets
WF->>WF: bun run db:migrate (working-dir: app/)
end
WF-->>GH: Job status (success/failure)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
|
||
| - name: Run migrations | ||
| working-directory: app | ||
| run: bun run db:migrate |
There was a problem hiding this comment.
Bug: Database Migration Workflow Vulnerabilities
The db-migrate.yml workflow has two issues. It lacks concurrency control, risking simultaneous database migrations and potential corruption. Additionally, using bun-version: latest creates non-deterministic builds, which could lead to unexpected migration failures from breaking changes in new Bun versions.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.github/workflows/db-migrate.yml (3)
21-23: Pin Bun version for reproducible builds.Using
latestcan cause inconsistent behavior across deployments. Consider pinning to a specific version.- with: - bun-version: latest + with: + bun-version: "1.1.29"
29-31: Add error handling and migration status verification.Consider adding steps to verify migration success and handle potential failures gracefully.
- name: Run migrations working-directory: app - run: bun run db:migrate + run: | + echo "Running database migrations..." + bun run db:migrate + echo "Migrations completed successfully"Additionally, consider adding a step to verify the database connection before running migrations:
- name: Verify database connection working-directory: app run: bun run db:check || echo "Database connection check failed"
1-32: Consider adding notification on migration failures.For production database migrations, consider adding Slack/email notifications on failure to ensure quick response to issues.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/db-migrate.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
.github/workflows/db-migrate.yml (2)
7-9: Path filters look correct for DB changes.The workflow properly triggers on schema file and migration directory changes. This ensures migrations run only when necessary.
14-15: Verify DATABASE_URL secret exists and points to production database.gh CLI returned HTTP 403 (Resource not accessible by integration) when listing secrets — verification failed. Confirm repository secret DATABASE_URL exists and targets the production DB used by main-branch deployments.
Location: .github/workflows/db-migrate.yml (env: DATABASE_URL, lines 14–15)
Add a GitHub Actions workflow to automatically run Drizzle migrations on
mainwhen schema or migration files are updated.Summary by CodeRabbit