fix: more pooler conn string updates (#20849)

* fix: swap examples for pooler conn string

* fix: clarify how to get pooler string in branching docs

* fix: double scrollbar caused by banner

* fix: more fixes to connection docs re: pooling

* update postgres images

* restore accidentally deleted image

* appease prettier

* update connecting guide

* Update add-pg-server-conn-info.png

* replace projectref with a placeholder

* spelling nit

* update image

---------

Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Inian <inian1234@gmail.com>
This commit is contained in:
authored and GitHub committed 2024-01-30 16:08:50 +08:00
1 parent 3f75f791a6
commit b5eb4066ae
25 files changed
+114 -103

No files matched your search

+3 -4
View File
@@ -267,7 +267,7 @@ const Container = memo(function Container(props: PropsWithChildren) {
id="docs-content-container"
className={[
// 'overflow-x-auto',
'w-full h-screen transition-all ease-out',
'w-full transition-all ease-out',
// 'absolute lg:relative',
mobileMenuOpen ? 'ml-[75%] sm:ml-[50%] md:ml-[33%] overflow-hidden' : 'overflow-auto',
// desktop override any margin styles
@@ -294,7 +294,6 @@ const NavContainer = memo(function NavContainer() {
'lg:left-0',
'transition-all',
'top-0',
'h-screen',
'flex flex-col ml-0',
].join(' ')}
>
@@ -352,8 +351,8 @@ const SiteLayout = ({ children }: PropsWithChildren<{}>) => {
<Head>
<title>Supabase Docs</title>
</Head>
<main>
<div className="flex flex-row h-screen">
<main className="grow overflow-hidden">
<div className="flex flex-row h-full">
<NavContainer />
<Container>
<div className={['lg:sticky top-0 z-10 overflow-hidden'].join(' ')}>
+7 -5
View File
@@ -191,16 +191,18 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
<>
<QueryClientProvider client={queryClient}>
<Favicons />
<IPv4DeprecationBanner />
<AuthContainer>
<SignOutHandler>
<ThemeProvider defaultTheme="system" enableSystem disableTransitionOnChange>
<CommandMenuProvider site="docs">
<TabsProvider>
<SiteLayout>
<PortalToast />
<Component {...pageProps} />
</SiteLayout>
<div className="h-screen flex flex-col">
<IPv4DeprecationBanner />
<SiteLayout>
<PortalToast />
<Component {...pageProps} />
</SiteLayout>
</div>
</TabsProvider>
</CommandMenuProvider>
</ThemeProvider>
@@ -12,12 +12,12 @@ export const meta = {
Supabase provides several options for programmatically connecting to your Postgres database:
1. Programmatic access using the Data APIs
1. Direct connections using the built-in Postgres connection system
1. Connection pooling for scalable connections
1. Direct connections using the built-in Postgres connection system
<Admonition type="caution">
Starting on <DateFormat date="2024-01-26" options={{ dateStyle: "long", timeZone: "UTC" }} />, direct database connections will start resolving to an IPv6 address. If you connect to your database using the REST and GraphQL endpoints, this doesn't affect you. If you use the database connection string, see the GitHub discussion on [how to prepare for IPv6](https://github.com/orgs/supabase/discussions/17817).
Direct database connections will start resolving to an IPv6 address. Starting from January 26, 2024, projects will be gradually migrated to this behavior. If you connect to your database using the REST or GraphQL endpoints, this doesn't affect you. If you use the database connection string, see the GitHub discussion on [how to prepare for IPv6](https://github.com/orgs/supabase/discussions/17817).
</Admonition>
@@ -31,37 +31,61 @@ Supabase provides auto-updating Data APIs. These are the easiest way to get star
## Connection pooler
Every Supabase project comes with a connection pooler for managing connections to your Postgres database.
A "connection pool" is a system (external to Postgres) which manages Postgres connections.
A connection pooler is useful for managing a large number of _temporary_ connections - for example, if you are using Prisma, Drizzle, Kysely, or anything deployed to a Serverless environment (AWS Lambdas or Edge Functions). Supabase's connection pooler also supports ipv4 out of the box.
When a client makes a request, the pooler "allocates" an available connection to the client. When the client transaction or session is completed the connection is returned to the pool and is free to be used by another client.
<figure>
<Image
className="hidden dark:block"
alt="New migration files trigger migrations on the preview instance."
src="/docs/img/guides/database/connecting-to-postgres/how-connection-pooling-works.png"
/>
<Image
className="dark:hidden"
alt="New migration files trigger migrations on the preview instance."
src="/docs/img/guides/database/connecting-to-postgres/how-connection-pooling-works--light.png"
/>
<figcaption>Connecting to the database directly vs using a Connection Pooler</figcaption>
</figure>
Every Supabase project comes with a connection pooler for managing connections to your database. The pooler provides 2 important services:
1. It manages connections for applications that connect and disconnect from the database frequently. For example, serverless functions and ORMs such as Prisma, Drizzle, and Kysely often make and drop connections to the database. If they connected directly each time, they would quickly exhaust your database server's memory. To connect to your database efficiently with such tools, you need a pooler.
2. It provides an IPv4 endpoint to connect to your database, which you can use if your network provider doesn't support IPv6. This is unlike the direct database connection, which resolves to an IPv6 address, unless you've enabled the [IPv4 add-on](https://supabase.com/docs/guides/platform/ipv4-address).
<Admonition type="tip">
The connection pooler is available in 2 modes: `Transaction` and `Session`.
</Admonition>
Transaction mode is recommended if you are connecting from serverless environments. A connection is assigned to the client for the duration of a transaction. Two consecutive transactions from the same client can be executed over two different connections. Some session-based Postgres features such as prepared statements are _not available_ with this option.
Session mode is similar to connecting to your database directly. There is full support for prepared statements in this mode. When a new client connects, a connection is assigned to the client until it disconnects. You might run into pooler connection limits since the connection is held till the client disconnects.
You can find the connection pool config in the [Database settings](/dashboard/project/_/settings/database) inside the dashboard:
1. Go to the `Settings` section.
2. Click `Database`.
3. Under `Connect to your database via connection pooling`, copy your `Connection string`.
3. Under `Connection string`, make sure `Use connection pooling` is checked. Copy the URI.
## Direct connections
You can use a direct connection to connect directly to your Postgres database. By default, this connection uses ipv6, which isn't supported by all network providers. If you need an ipv4 address, use the [connection pooler](#connection-pooler) instead.
You can also use a direct connection to connect directly to your Postgres database. By default, you can connect to it via IPv6, which isn't supported by all networks. If you need an IPv4 address, use the [connection pooler](#connection-pooler) instead or enable the [IPv4 add-on](https://supabase.com/docs/guides/platform/ipv4-address).
You can find the direct connection string in the [Database settings](https://supabase.com/dashboard/project/_/settings/database) inside the dashboard:
1. Go to the `Settings` section.
2. Click `Database`.
3. Under `Connect to your database directly`, copy your `Connection string`.
3. Under `Connection string`, make sure `Use connection pooling` is unchecked. Copy the URI.
## Choosing a connection method
- The Data APIs provide programmatic access and have [built-in connection pooling](https://postgrest.org/en/stable/references/connection_pool.html). You can use these for all browser and application interactions. We recommend using these wherever possible.
- A "connection pooler" is a tool which keeps connections "alive". You should use this for serverless functions and tools which disconnect from the database frequently, like Prisma, Drizzle, Kysely, etc. You should also use this if your network doesn't support ipv6.
- A "direct connection" is Postgres' native connection system. You can use this for tools which are always alive, such as long-running server, as long as your network supports ipv6.
Why would you use a connection pool? Primarily because the way that Postgres handles connections isn't very scalable for a large number of _temporary_ connections. You can use these simple questions to determine which connection method to use:
- Are you on a network that doesn't support ipv6? Use the connection pooler.
- Are you connecting to your database and then _disconnecting_ immediately (e.g. a serverless environment)? Use the connection pooler.
- Are you connecting to a database and _maintaining_ a connection, and does your network support ipv6? If yes, use a direct connection.
- Are you performing operations supported by the Data APIs? We recommend using the APIs.
- Are you connecting to your database and then _disconnecting_ immediately (for example, are you running your code in a serverless environment)? Use the connection pooler in transaction mode.
- Are you on a network that doesn't support IPv6? Use the connection pooler. (If you need a long-lived connection, for example for prepared statements, use session mode.)
- Are you connecting to your database and _maintaining_ a connection, and does your network support IPv6? Use a direct connection.
## Connecting with SSL
@@ -108,7 +132,7 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Code>
```ts
```ts schema.ts
import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
export const users = pgTable('users', {
@@ -126,24 +150,25 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Details title="Connect">
Connect to your database using the Connection Pooler for serverless environments, and the Direct Connection for long-running servers.
Connect to your database using the Connection Pooler.
In your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/database), make sure `Use connection pooler` is checked, then copy the URI and save it as the `DATABASE_URL` environment variable. Remember to replace the password placeholder with your actual database password.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
```ts
```ts db.ts
import 'dotenv/config'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import { users } from './schema'
const connectionString = process.env.DATABASE_URL
// Disable prefetch as it is not supported for "Transaction" pool mode
const client = postgres(connectionString, { prepare: false })
const db = drizzle(client);
const allUsers = await db.select().from(users);
export const client = postgres(connectionString, { prepare: false })
export const db = drizzle(client);
```
</StepHikeCompact.Code>
@@ -168,7 +193,16 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Code>
![Register a new postgres server.](/docs/img/guides/database/register-server-pgAdmin.png)
<Image
className="hidden dark:block"
alt="Register a new postgres server."
src="/docs/img/guides/database/connecting-to-postgres/pgadmin/register-server-pgAdmin.png?v=2"
/>
<Image
className="dark:hidden"
alt="Register a new postgres server."
src="/docs/img/guides/database/connecting-to-postgres/pgadmin/register-server-pgAdmin--light.png"
/>
</StepHikeCompact.Code>
@@ -184,7 +218,7 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Code>
![Name Postgres Server.](/docs/img/guides/database/name-pg-server.png)
![Name Postgres Server.](/docs/img/guides/database/connecting-to-postgres/pgadmin/name-pg-server.png)
</StepHikeCompact.Code>
@@ -194,13 +228,13 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Details title="Connect">
Add the connection info. You can use the "Direct connection" config, which you can find in your Supabase dashboard.
Add the connection info. Go to your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/database). Make sure `Use connection pooling` is enabled. Switch the connection mode to `Session` and copy your connection parameters.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
![Add Connection Info.](/docs/img/guides/database/add-pg-server-conn-info.png)
![Add Connection Info.](/docs/img/guides/database/connecting-to-postgres/pgadmin/add-pg-server-conn-info.png)
</StepHikeCompact.Code>
@@ -216,7 +250,7 @@ You can obtain your connection info and Server root certificate from your applic
<StepHikeCompact.Code>
![Add Connection Info.](/docs/img/guides/database/add-ssl-config-parameter.png)
![Add Connection Info.](/docs/img/guides/database/connecting-to-postgres/pgadmin/database-settings-host.png)
</StepHikeCompact.Code>
@@ -228,10 +262,12 @@ You can obtain your connection info and Server root certificate from your applic
[`psql`](https://www.postgresql.org/docs/current/app-psql.html) is a command-line tool that comes with Postgres.
Assuming you've downloaded your SSL certificate to `$HOME/Downloads/prod-supabase.cer`, and your host address is `db.ref.supabase.co` you connect to your database via SSL:
Download your [SSL certificate](#connecting-with-ssl) to `/path/to/prod-supabase.cer`.
Find your connection settings. Go to your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/database) and make sure `Use connection pooling` is checked. Change the connection mode to `Session`, and copy the parameters into the connection string:
```shell
psql "sslmode=verify-full sslrootcert=$HOME/Downloads/prod-supabase.cer host=db.ref.supabase.co dbname=postgres user=postgres"
psql "sslmode=verify-full sslrootcert=/path/to/prod-supabase.cer host=[CLOUD_PROVIDER]-0-[REGION]-1.pooler.supabase.com dbname=postgres user=postgres.[PROJECT_REF]"
```
### Connecting with Prisma
@@ -266,7 +302,9 @@ Refer to our [Prisma integration guide](https://supabase.com/partners/integratio
<StepHikeCompact.Details title="Connect">
Create a `db.js` file with the connection details. Use the Connection Pooler for serverless environments, and the Direct Connection for long-running servers.
Create a `db.js` file with the connection details.
To get your connection details, go to your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/database). Make sure `Use connection pooling` is enabled. Choose `Transaction Mode` if you're on a platform with transient connections, such as a serverless function, and `Session Mode` if you have a long-lived connection. Copy the URI and save it as the environment variable `DATABASE_URL`.
</StepHikeCompact.Details>
@@ -316,36 +354,6 @@ Refer to our [Prisma integration guide](https://supabase.com/partners/integratio
</StepHikeCompact>
## How connection pooling works
A "connection pool" is a system (external to Postgres) which manages Postgres connections.
When a client makes a request, the pooler "allocates" an available connection to the client. When the client transaction or session is completed the connection is returned to the pool and is free to be used by another client.
![Connection pooling](/docs/img/guides/database/connection-pool.png)
There are several pool modes, each handling connections differently:
### Session
When a new client connects, a connection is assigned to the client until it disconnects. Afterward, the connection is returned back to the pool.
All Postgres features can be used with this option.
### Transaction
This is the suggested option for serverless functions. A connection is assigned to the client for the duration of a transaction. Two consecutive transactions from the same client could be executed over two different connections. Some session-based Postgres features such as prepared statements are not available with this option.
### Supavisor vs PgBouncer
Supabase previously used PgBouncer for connection pooling. We have now deprecated PgBouncer in favor of Supavisor. Supavisor is available on all new and existing projects.
[Supavisor](https://github.com/supabase/supavisor) is a new connection pooler by Supabase that runs on a high-availability cluster, segregated from your database. This means more resources are available for your database. No Application changes are required to switch from PgBouncer to Supavisor, you simply need to choose the new connection string from the "Connection Pooling" section on [Database settings](https://supabase.com/dashboard/project/_/settings/database).
PgBouncer is now deprecated and is in the process of being removed from the platform, you can [see full details and timelines of the deprecation on Github Discussions](https://github.com/orgs/supabase/discussions/17817). Additionally, your Supabase database domain (db.projectref.supabase.co) will start resolving to an IPv6 address. No changes are required if your network supports IPv6. Otherwise, update your applications to use Supavisor which will continue to support IPv4 connections.
[Read the full pgBouncer and IPv4 deprecation details](https://github.com/orgs/supabase/discussions/17817).
## Troubleshooting Supavisor
Connection pooler logs are found [here](https://supabase.com/dashboard/project/_/logs/pooler-logs). The following are common errors and their solutions:
@@ -8,7 +8,7 @@ export const meta = {
Your Postgres database is the core of your Supabase project, so it's important that it has a strong, secure password at all times.
If you use special symbols in your postgres password, you must remember to [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) your password later if using the postgres connection string e.g. `postgresql://postgres:p%3Dword@db.cvwawazfelidkloqmbma.supabase.co:5432/postgres`
If you use special symbols in your postgres password, you must remember to [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) your password later if using the postgres connection string e.g. `postgresql://postgres.projectref:p%3Dword@aws-0-us-east-1.pooler.supabase.com:6543/postgres`
## Changing your project password
@@ -40,7 +40,7 @@ Your Postgres database is the core of your Supabase project, so it's important t
### Special symbols in passwords
If you use special symbols in your Postgres password, you must remember to [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) your password later if using the Postgres connection string e.g. `postgresql://postgres:p%3Dword@db.xxx.supabase.co:5432/postgres`.
If you use special symbols in your postgres password, you must remember to [percent-encode](https://en.wikipedia.org/wiki/Percent-encoding) your password later if using the postgres connection string e.g. `postgresql://postgres.projectref:p%3Dword@aws-0-us-east-1.pooler.supabase.com:6543/postgres`
### Changing your project password
@@ -52,11 +52,13 @@ export const meta = {
Go to [database.new](https://database.new) and create a new Supabase project. Save your database password securely.
When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string.
When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string. Make sure **Use connection pooling** is checked and **Session mode** is selected. Then copy the URI. Replace the password placeholder with your saved database password.
In this quickstart, we are going to connect via the connection pooler. Make sure to select `Session mode`! If your network supports IPv6, you can connect to the database directly without using the connection pooler.
<Admonition type="tip">
Laravel ships with a Postgres adapter out of the box, you can simply configure it via the environment variables. You can find the database URL in your [Supabase Dashboard](/dashboard/project/_/settings/database).
If your network supports IPv6 connections, you can also use the direct connection string. Uncheck **Use connection pooling** and copy the new URI.
</Admonition>
</StepHikeCompact.Details>
@@ -34,11 +34,13 @@ export const meta = {
Go to [database.new](https://database.new) and create a new Supabase project. Save your database password securely.
When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string.
When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string. Make sure **Use connection pooling** is checked and **Session mode** is selected. Then copy the URI. Replace the password placeholder with your saved database password.
In this quickstart, we are going to connect via the connection pooler. Make sure to select `Session mode`! If your network supports IPv6, you can connect to the database directly without using the connection pooler.
<Admonition type="tip">
Rails ships with a Postgres adapter included, you can simply configure it via the environment variables. You can find the database URL in your [Supabase Dashboard](/dashboard/project/_/settings/database).
If your network supports IPv6 connections, you can also use the direct connection string. Uncheck **Use connection pooling** and copy the new URI.
</Admonition>
</StepHikeCompact.Details>
@@ -149,7 +149,7 @@ You can use the [Supabase CLI](/docs/guides/cli) to manage changes inside a loca
<StepHikeCompact.Step step={2}>
<StepHikeCompact.Details title="Pull your database migration" fullWidth>
Pull your database changes using `supabase db pull`. You can find your database URL in your [database settings](https://supabase.com/dashboard/project/_/settings/database), under the URI tab of the Connection String settings panel.
Pull your database changes using `supabase db pull`. You can find your database URL in your [database settings](https://supabase.com/dashboard/project/_/settings/database), under the URI tab of the Connection String settings panel. Make sure **Use connection pooling** is checked so you can use the IPv4-enabled connection pooler. (Without connection pooling, your database is only accessible over IPv6, which isn't yet supported by all network providers.)
<CH.Code lineNumbers={false}>
@@ -123,13 +123,7 @@ Migrating projects can be achieved using the Supabase CLI. This is particularly
- Create a new [Supabase project](https://supabase.com/dashboard).
- Install [Docker Desktop](https://www.docker.com) for your platform.
- Set environment variables for the old project's database URL as `$OLD_DB_URL` and the new project's as `$NEW_DB_URL`.
To find the database URL for a project, go to the project's dashboard page [Project Settings/Database](https://supabase.com/dashboard/project/_/settings/database) and look at `Connection string / URI`. For example, to set the `$OLD_DB_URL` you would run `export OLD_DB_URL=postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF#].supabase.co:5432/postgres`.
<Admonition type="tip">
Note that this direct connection string to the database uses IPv6. If your network provider doesn't yet support IPv6, you can connect via the pooler connection string, available under the **Connection pooling** section of [**Database settings**](https://supabase.com/dashboard/project/_/settings/database). The connection string has the format `postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres`.
</Admonition>
To find the database URL for a project, go to the project's dashboard page [Project Settings/Database](https://supabase.com/dashboard/project/_/settings/database) and look under `Connection string`. If your network provider supports IPv6, you can disable `Use connection pooling`. Otherwise, enable `Use connection pooling`. For the pooler mode, `Transaction` will work.
### Backup your old database
@@ -58,10 +58,12 @@ Alternatively, you can use [pgloader](https://github.com/dimitri/pgloader), a fl
Install pgloader.
Create a configuration file (e.g., config.load).
For your destination, use your Supabase connection string with `Use connection pooling` enabled, and the mode set to `Session`. You can get the string from your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/general).
```sql
load database
from mysql://user:password@host/source_db
into postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres
into postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres
alter schema 'public' owner to 'postgres';
set wal_buffers = '64MB', max_wal_senders = 0, statement_timeout = 0, work_mem to '2GB';
```
@@ -33,7 +33,7 @@ git clone https://github.com/supabase-community/firebase-to-supabase.git
```
1. Go to the [Database settings](https://supabase.com/dashboard/project/_/settings/database) for your project in the Supabase Dashboard.
1. Under **Connection Info**, copy the Host string and replace the entry in your `supabase-service.json` file.
1. Under `Connection parameters`, enable `Use connection pooling` and set the mode to `Session`. Replace the `Host` and `User` fields with the values shown.
1. Enter the password you used when you created your Supabase project in the `password` entry in the `supabase-service.json` file.
## Generate a Firebase private key [#generate-firebase-private-key]
@@ -32,7 +32,7 @@ git clone https://github.com/supabase-community/firebase-to-supabase.git
```
1. Go to the [Database settings](https://supabase.com/dashboard/project/_/settings/database) for your project in the Supabase Dashboard.
1. Under **Connection Info**, copy the Host string and replace the entry in your `supabase-service.json` file.
1. Under `Connection parameters`, enable `Use connection pooling` and set the mode to `Session`. Replace the `Host` and `User` fields with the values shown.
1. Enter the password you used when you created your Supabase project in the `password` entry in the `supabase-service.json` file.
## Generate a Firebase private key [#generate-firebase-private-key]
@@ -34,11 +34,11 @@ Alternatively, use the [Heroku to Supabase migration tool](https://migrate.supab
- User (`$HEROKU_USER`)
- Password (`$HEROKU_PASSWORD`)
## Retrieve your Supabase host [#retrieve-supabase-host]
## Retrieve your Supabase connection string [#retrieve-supabase-connection-string]
1. If you're new to Supabase, [create a project](https://supabase.com/dashboard).
1. Go to the [Database settings](https://supabase.com/dashboard/project/_/settings/database) for your project in the Supabase Dashboard.
1. Under **Connection Info**, note your Host (`$SUPABASE_HOST`).
1. Under **Connection string**, make sure `Use connection pooling` is enabled. Copy the URI and replace the password placeholder with your database password.
## Export your Heroku database to a file [#export-heroku-database]
@@ -55,7 +55,7 @@ pg_dump --clean --if-exists --quote-all-identifiers \
Use `psql` to import the Heroku database file to your Supabase project.
```bash
psql -h $SUPABASE_HOST -U postgres -f heroku_dump.sql
psql -d "$YOUR_CONNECTION_STRING" -f heroku_dump.sql
```
## Additional options
@@ -55,10 +55,12 @@ Alternatively, you can use [pgloader](https://github.com/dimitri/pgloader), a fl
Install pgloader.
Create a configuration file (e.g., config.load).
For your destination, use your Supabase connection string with `Use connection pooling` enabled, and the mode set to `Session`. You can get the string from your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/general).
```sql
LOAD DATABASE
FROM mssql://USER:PASSWORD@HOST/SOURCE_DB
INTO postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres
INTO postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres
ALTER SCHEMA 'public' OWNER TO 'postgres';
set wal_buffers = '64MB', max_wal_senders = 0, statement_timeout = 0, work_mem to '2GB';
```
@@ -56,10 +56,12 @@ Alternatively, you can use [pgloader](https://github.com/dimitri/pgloader), a fl
Install pgloader.
Create a configuration file (e.g., config.load).
For your destination, use your Supabase connection string with `Use connection pooling` enabled, and the mode set to `Session`. You can get the string from your [`Database Settings`](https://supabase.com/dashboard/project/_/settings/general).
```sql
load database
from mysql://user:password@host/source_db
into postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres
into postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres
alter schema 'public' owner to 'postgres';
set wal_buffers = '64MB', max_wal_senders = 0, statement_timeout = 0, work_mem to '2GB';
```
@@ -21,13 +21,13 @@ Example:
%env PSQL_COMMAND=PGPASSWORD=RgaMDfTS_password_FTPa7 psql -h dpg-a_server_in.oregon-postgres.provider.com -U my_db_pxl0_user my_db_pxl0
```
## Retrieve your Supabase host [#retrieve-supabase-host]
## Retrieve your Supabase connection string [#retrieve-supabase-connection-string]
1. If you're new to Supabase, [create a project](https://supabase.com/dashboard).
Make a note of your password, you will need this later. If you forget it, you can [reset it here](https://supabase.com/dashboard/project/_/settings/database).
1. Go to the [Database settings](https://supabase.com/dashboard/project/_/settings/database) for your project in the Supabase Dashboard.
1. Under **Connection Info**, note your Host (`$SUPABASE_HOST`).
1. Under **Connection string**, make sure `Use connection pooling` is enabled. Copy the URI and replace the password placeholder with your database password.
![Finding Supabase host address](/docs/img/guides/resources/migrating-to-supabase/postgres/database-settings-host.png)
@@ -66,7 +66,7 @@ pg_dump --clean --if-exists --quote-all-identifiers \
Use `psql` to import the Postgres database file to your Supabase project.
```bash
psql -h $SUPA_URL -U postgres --file dump.sql -p 6543 -d postgres
psql -d "$YOUR_CONNECTION_STRING" -f dump.sql
```
### Additional options
@@ -25,15 +25,13 @@ Example:
%env PSQL_COMMAND=PGPASSWORD=RgaMDfTS_password_FTPa7 psql -h dpg-a_server_in.oregon-postgres.render.com -U my_db_pxl0_user my_db_pxl0
```
## Retrieve your Supabase host [#retrieve-supabase-host]
## Retrieve your Supabase connection string [#retrieve-supabase-connection-string]
1. If you're new to Supabase, [create a project](https://supabase.com/dashboard).
Make a note of your password, you will need this later. If you forget it, you can [reset it here](https://supabase.com/dashboard/project/_/settings/database).
1. Go to the [Database settings](https://supabase.com/dashboard/project/_/settings/database) for your project in the Supabase Dashboard.
1. Under **Connection Info**, note your Host (`$SUPABASE_HOST`).
![Finding Supabase host address](/docs/img/guides/resources/migrating-to-supabase/render/database-settings-host.png)
1. Under **Connection string**, make sure `Use connection pooling` is enabled. Copy the URI and replace the password placeholder with your database password.
## Migrate the database
@@ -70,7 +68,7 @@ pg_dump --clean --if-exists --quote-all-identifiers \
Use `psql` to import the Render database file to your Supabase project.
```bash
psql -h $SUPA_URL -U postgres --file render_dump.sql -p 6543 -d postgres
psql -d "$YOUR_CONNECTION_STRING" -f render_dump.sql
```
### Additional options
Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB