Skip to content

Latest commit

 

History

History
97 lines (67 loc) · 3.67 KB

supabase_postgres_peerdb_cloud.mdx

File metadata and controls

97 lines (67 loc) · 3.67 KB
title
Supabase Postgres Source Setup Guide on PeerDB Cloud

This is a guide on how to create a supabase PostgreSQL peer which you can use for replication in PeerDB. PeerDB Cloud supports Supabase via IPv6 for seemless replication.

Let's create a new user for PeerDB with the necessary permissions suitable for CDC, and also create a publication that we'll use for replication.

For this, you can head over to the SQL Editor for your Suapabase Project. Here, we can run the following SQL commands:

  CREATE USER peerdb_user PASSWORD 'peerdb_password';
  GRANT USAGE ON SCHEMA "public" TO peerdb_user;
  GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO peerdb_user;
  ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO peerdb_user;

-- Give replication permission to the USER
  ALTER USER peerdb_user REPLICATION;

-- Create a publication with the tables you wish to replicate. We will use this when creating the mirror
  CREATE PUBLICATION peerdb_publication FOR TABLE table1, table2, table3....;

Click on Run to have a publication and a user ready. Make sure to replace peerdb_user and peerdb_password with your desired username and password.

Also, remember to use the same publication name when creating the mirror in PeerDB.

Make sure you are signed in to your [Supabase console](https://supabase.com/) for this step.

Creating the Supabase Peer in PeerDB Cloud is as simple as granting PeerDB access to your Supabase Project.

  1. Head over to the PeerDB UI and click on Create Peer. Select Supabase as the source.

  1. You should be redirected to Supabase to authorize PeerDB to access your Supabase Project. Make sure to select the correct organization from the dropdown and click on Authorize PeerDB.

  1. You should now see a list of your Supabase Projects. Click on the project you want to create the peer for.

  1. Once you select the project, you should see a screen like below with connection details filled in automatically. Fill in the username and password you created earlier in the SQL Editor in Step 1.

  1. Click on Validate and once that's green, you can go ahead and click on Create to create the peer!
This is a recommended configuration change to ensure that large transactions/commits do not cause the replication slot to be dropped. This step will restart your Supabase database and may cause a brief downtime.

You can increase the max_slot_wal_keep_size parameter for your Supabase database to a higher value (at least 100GB or 102400) by following the Supabase Docs

For better recommendation of this value you can contact the PeerDB team.

When creating the Mirror, make sure to reuse the same publication you created earlier in Step 1