feat(NES-47): support Supabase migrations and session store over the pooler - #65
Conversation
…pooler - config: add MIGRATE_DATABASE_URL (DBConfig.MigrateDSN); empty reuses DATABASE_URL, so operators can run migrations against the Supabase direct/session connection while the app server points at the transaction pooler. - migrate: add a variadic Option API with PoolerSafe(), which opens the database/sql handle via stdlib.OpenDB with the simple query protocol so goose version bookkeeping does not rely on named server-side prepared statements through a transaction pooler. The default path is unchanged. - cmd/migrate: resolve the effective migrate DSN and enable pooler-safe only when migrations would otherwise run through the Supabase transaction pooler (no dedicated migrate DSN, provider supabase, pool mode transaction). - tests: unit-test the pooler-safe conn config, the migrateSettings decision, and the MIGRATE_DATABASE_URL config capture; add a DB-gated test that exercises scs/pgxstore create/read/refresh/delete under QueryExecModeExec. - docs: document MIGRATE_DATABASE_URL and the session-connection requirement in the README migrations section. Why: goose DDL/bookkeeping and pgxstore must work correctly against Supabase. Migrations need a session connection; the app pool runs pooler-safe exec mode (NES-46), and pgxstore inherits it, so this confirms and pins that behavior.
|
Warning Review limit reached
More reviews will be available in 49 minutes and 55 seconds. Learn how PR review limits work. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughAdds ChangesPooler-safe migration support
Possibly related issues
Possibly related PRs
🚥 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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 137-146: The MIGRATE_DATABASE_URL configuration variable is
documented in the migration section but is missing from the configuration table
at lines 41-52. Add a new row to the configuration table after the DATABASE_URL
entry that documents MIGRATE_DATABASE_URL as an optional variable that defaults
to DATABASE_URL if not set, and include a brief description explaining its
purpose for running migrations against a different database connection (useful
for Supabase with session connections).
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ab6fbd97-59e0-420b-82f6-6e6c804595d0
📒 Files selected for processing (8)
README.mdcmd/migrate/main.gocmd/migrate/main_test.gointernal/auth/adapter/session_pooler_test.gointernal/platform/config/config.gointernal/platform/config/config_test.gointernal/platform/db/migrate/migrate.gointernal/platform/db/migrate/migrate_test.go
Summary
Makes the two stateful Postgres consumers — goose schema migrations and the scs/pgxstore session store — work correctly against Supabase (NES-47). Builds on the connection/exec-mode plumbing from NES-46.
Changes
MIGRATE_DATABASE_URL(DBConfig.MigrateDSN). Empty means "reuseDATABASE_URL"; operators point it at the Supabase direct/session connection (port 5432) so DDL and goose version bookkeeping run on a session connection while the app server uses the transaction pooler (6543).OptionAPI withPoolerSafe(). The pooler-safe path opens thedatabase/sqlhandle viastdlib.OpenDBconfigured for the simple query protocol, so goose's bookkeeping carries no named server-side prepared statements through a transaction pooler. The default path is unchanged.migrateSettingsresolves the effective DSN and enables pooler-safe only when migrations would otherwise run through the Supabase transaction pooler (no dedicated migrate DSN +DB_PROVIDER=supabase+DB_POOL_MODE=transaction). The preferred path is a direct/sessionMIGRATE_DATABASE_URL.QueryExecModeExecfrom NES-46 — no code change. A DB-gated test pins create/read/refresh/delete under exec mode.poolerSafeConnConfig(simple protocol),migrateSettings(DSN + option selection), and theMIGRATE_DATABASE_URLconfig capture; plus the DB-gated session-store test. No live DB required for the unit tests.MIGRATE_DATABASE_URLand the session-connection requirement.Acceptance criteria
migrate up|down|status|resetworks against a Supabase database (direct/session); existingmigrate_test.goround-trip runs against anyNESTOVA_TEST_DATABASE_URLincluding Supabase.MIGRATE_DATABASE_URLis used when set; otherwiseDATABASE_URL, no behavior change for existing Postgres.Jira: NES-47
Summary by CodeRabbit
Release Notes
New Features
MIGRATE_DATABASE_URLenvironment variable, enabling migrations to target a dedicated connection when required.Documentation