diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 925f8404bd9..00322724739 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -755,6 +755,10 @@ export const database: NavMenuConstant = {
url: '/guides/database/postgres/roles',
},
{ name: 'Managing secrets with Vault', url: '/guides/database/vault' },
+ {
+ name: 'Superuser Access and Unsupported Operations',
+ url: '/guides/database/postgres/roles-superuser',
+ },
],
},
{
@@ -942,6 +946,10 @@ export const database: NavMenuConstant = {
name: 'Print PostgreSQL Version',
url: '/guides/database/postgres/which-version-of-postgres',
},
+ {
+ name: 'Replicating from Supabase to External Postgres',
+ url: '/guides/database/postgres/setup-replication-external',
+ },
],
},
],
diff --git a/apps/docs/pages/guides/database/postgres/roles-superuser.mdx b/apps/docs/pages/guides/database/postgres/roles-superuser.mdx
new file mode 100644
index 00000000000..1ec3f5064b7
--- /dev/null
+++ b/apps/docs/pages/guides/database/postgres/roles-superuser.mdx
@@ -0,0 +1,25 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'roles',
+ title: 'Roles, superuser access and unsupported operations',
+ slug: 'roles',
+}
+
+Supabase provides the default `postgres` role to all instances deployed. Superuser access is not given as it allows destructive operations to be performed on the database.
+
+To ensure you are not impacted by this, additional privileges are granted to the `postgres` user to allow it to run some operations that are normally restricted to superusers.
+
+However, this does mean that some operations, that typically require `superuser` privileges, are not available on Supabase. These are documented below:
+
+## Unsupported operations
+
+- `CREATE ROLE ... WITH REPLICATION`
+- `CREATE SUBSCRIPTION`
+- `CREATE EVENT TRIGGER`
+- `COPY ... FROM PROGRAM`
+- `ALTER USER ... WITH SUPERUSER`
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/database/postgres/setup-replication-external.mdx b/apps/docs/pages/guides/database/postgres/setup-replication-external.mdx
new file mode 100644
index 00000000000..1633f40900b
--- /dev/null
+++ b/apps/docs/pages/guides/database/postgres/setup-replication-external.mdx
@@ -0,0 +1,68 @@
+import { createDecipheriv } from 'crypto'
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ title: 'Replicate to another Postgres database using Logical Replication',
+ description:
+ 'Example to setup logical replication using publish-subscribe to a Postgres database outside of Supabase',
+ footerHelpType: 'postgres',
+}
+
+For this example, you will need:
+
+- A Supabase project
+- A PostgreSQL database (running v10 or newer)
+
+You will be running commands on both of these databases to publish changes from the Supabase database to the external database.
+
+1. Create a `publication` on the **Supabase database**:
+
+```sql
+CREATE PUBLICATION example_pub;
+```
+
+2. Also on the **Supabase database**, create a `replication slot`:
+
+```sql
+select pg_create_logical_replication_slot('example_slot', 'pgoutput');
+```
+
+3. Now we will connect to our **external database** and subscribe to our `publication` Note: ):
+
+
+
+This will need a direct connection to your database and you can find the connection info in the [Dashboard](https://supabase.com/dashboard/project/_/settings/database).
+
+You will also need to ensure that ipv6 is supported by your replication destination.
+
+
+
+```sql
+CREATE SUBSCRIPTION example_sub
+CONNECTION 'host=db.oaguxblfdassqxvvwtfe.supabase.co user=postgres password=YOUR_PASS dbname=postgres'
+PUBLICATION example_pub
+WITH (copy_data = true, create_slot=false, slot_name=example_slot);
+```
+
+
+
+`create_slot` is set to `false` because `slot_name` is provided and the slot was already created in Step 2.
+To copy data from before the slot was created, set `copy_data` to `true`.
+
+
+
+4. Add all the tables that you want replicated to the publication.
+
+```sql
+ALTER PUBLICATION example_pub ADD TABLE example_table;
+```
+
+5. Check the replication status using `pg_stat_replication`
+
+```sql
+select * from pg_stat_replication;
+```
+
+export const Page = ({ children }) =>
+
+export default Page