feat(dashboard-agent-db): run migrations over a direct (non-pooler) connection#4054
Conversation
…onnection A transaction-mode pooler can't run the migrator (no advisory locks, no multi-statement DDL), so the agent datastore now resolves its migration connection from a dedicated DASHBOARD_AGENT_DIRECT_URL, falling back to the pooled DASHBOARD_AGENT_DATABASE_URL, then the main DIRECT_URL / DATABASE_URL for the single-database fallback. The application keeps using the pooled DASHBOARD_AGENT_DATABASE_URL. Only the migration entry points (drizzle.config.ts, migrate.mjs, migrate-status.mjs) changed; the runtime client is untouched.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📜 Recent review details⏰ Context from checks skipped due to timeout. (24)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.ts📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
Files:
**/*.{js,ts,tsx,jsx,css,json,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (9)📚 Learning: 2026-03-22T13:26:12.060ZApplied to files:
📚 Learning: 2026-03-22T19:24:14.403ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-06-13T19:53:13.759ZApplied to files:
📚 Learning: 2026-06-17T17:13:49.929ZApplied to files:
📚 Learning: 2026-06-23T13:04:21.413ZApplied to files:
📚 Learning: 2026-06-04T18:16:35.386ZApplied to files:
📚 Learning: 2026-06-09T17:58:04.699ZApplied to files:
🔇 Additional comments (4)
WalkthroughThe PR updates database connection-string resolution for migration-related code to prefer 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Summary
The in-dashboard agent's datastore now runs migrations over a direct (non-pooler) connection. A transaction-mode pooler can't run the migrator (no advisory locks, no multi-statement DDL), so when the agent's database sits behind a pooler the migration step needs a separate direct connection.
The application keeps connecting over the pooled
DASHBOARD_AGENT_DATABASE_URL. Only the migration entry points changed (drizzle.config.ts,migrate.mjs,migrate-status.mjs); the runtime client is untouched.Connection resolution (migrations)
Mirrors the existing
DATABASE_URL/DIRECT_URLsplit. Fully backward-compatible: with nothing new set, resolution is identical to before. The agent-specific vars take precedence over the mainDIRECT_URL, so a separate agent database is never migrated against the wrong one. When the agent falls back to the main single database, migrations now prefer its direct connection.