Skip to content

Commit

Permalink
Update PgBouncer -> Supavisor (#5584)
Browse files Browse the repository at this point in the history
* Update Supabase docs to reference Supavisor instead of PgBouncer
Fixes #5565

* Update content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/200-pgbouncer.mdx

* Update content/200-orm/050-overview/500-databases/880-supabase.mdx

Co-authored-by: Joël Galeran <[email protected]>

* Apply suggestions from code review

Co-authored-by: Joël Galeran <[email protected]>

---------

Co-authored-by: Joël Galeran <[email protected]>
  • Loading branch information
jharrell and Jolg42 authored Jan 22, 2024
1 parent e0e1f8d commit 1cb40c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions content/200-orm/050-overview/500-databases/880-supabase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ Many aspects of using Prisma with Supabase are just like using Prisma with any o

## Specific considerations

If you'd like to use the [connection pooling feature](https://supabase.com/docs/guides/integrations/prisma#connection-pooling-with-supabase) available with Supabase, you will
need to add `pgbouncer=true` to the end of the `DATABASE_URL` environment variable used in the `datasource.url` property:
If you'd like to use the [connection pooling feature](https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pooler) available with Supabase, you will need to use the connection pooling connection string available via your [Supabase database settings](https://supabase.com/dashboard/project/_/settings/database) with `?pgbouncer=true` appended to the end of your `DATABASE_URL` environment variable:

```env file=.env
# Connect to Supabase with PgBouncer.
DATABASE_URL="postgres://postgres.__YOUR_SUPABASE_PROJECT__:__PASSWORD__@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
# Connect to Supabase via connection pooling with Supavisor.
DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
```

If you would like to use the Prisma CLI in order to perform other actions on your database (e.g. migrations) you will need to add a `DIRECT_URL` environment variable to use in the `datasource.directUrl` property so that the CLI can bypass PgBouncer:
If you would like to use the Prisma CLI in order to perform other actions on your database (e.g. migrations) you will need to add a `DIRECT_URL` environment variable to use in the `datasource.directUrl` property so that the CLI can bypass Supavisor:

```env file=.env highlight=4-5;add
# Connect to Supabase with PgBouncer.
DATABASE_URL="postgres://postgres.__YOUR_SUPABASE_PROJECT__:__PASSWORD__@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
# Connect to Supabase via connection pooling with Supavisor.
DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
# Direct connection to the database. Used for migrations.
DIRECT_URL="postgres://postgres:__PASSWORD__@db.__YOUR SUPABASE_PROJECT__.supabase.co:5432/postgres"
DIRECT_URL="postgres://postgres:[password]@db.[your-supabase-project].supabase.co:5432/postgres"
```

You can then update your `schema.prisma` to use the new direct URL:
Expand All @@ -62,7 +61,7 @@ More information about the `directUrl` field can be found [here](/orm/reference/

<Admonition type="info">

We strongly recommend using `pgbouncer` in addition to `DIRECT_URL`. You will gain the great developer experience of the Prisma CLI while also allowing for connections to be pooled regardless of deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling.
We strongly recommend using connection pooling with Supavisor in addition to `DIRECT_URL`. You will gain the great developer experience of the Prisma CLI while also allowing for connections to be pooled regardless of your deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling.

</Admonition>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Below are links to information on how to set up these connections with providers

## Supabase Supavisor

Supabase's Supavisor behaves similar to [PgBouncer](#pgbouncer). You can add `pgbouncer=true` to your connection pooled connection string.
Supabase's Supavisor behaves similarly to [PgBouncer](#pgbouncer). You can add `?pgbouncer=true` to your connection pooled connection string available via your [Supabase database settings](https://supabase.com/dashboard/project/_/settings/database).

## Other external connection poolers

Expand Down

1 comment on commit 1cb40c3

@vercel
Copy link

@vercel vercel bot commented on 1cb40c3 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./

prisma2-docs.vercel.app
docs-git-main-prisma.vercel.app
docs-prisma.vercel.app

Please sign in to comment.