Skip to content

Commit f2a0139

Browse files
singh-inderawaseemaantti
authored
fix(QueuesSettings): skip PostgREST config update for self-hosted projects (supabase#40078)
* fix(QueuesSettings): skip PostgREST config update for self-hosted projects * docs(queues): add guide to expose self-hosted queues * feat(QueuesSettings): add docs link for exposing pgmq_public schema in self-hosted instance * fix ui, open link in new tab * fix lint issues --------- Co-authored-by: Ali Waseem <[email protected]> Co-authored-by: Andrey A. <[email protected]>
1 parent 4108848 commit f2a0139

File tree

3 files changed

+91
-11
lines changed

3 files changed

+91
-11
lines changed

apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,10 @@ export const queues: NavMenuConstant = {
14081408
name: 'Consuming Messages with Edge Functions',
14091409
url: '/guides/queues/consuming-messages-with-edge-functions',
14101410
},
1411+
{
1412+
name: 'Expose Queues for local and self-hosted Supabase',
1413+
url: '/guides/queues/expose-self-hosted-queues',
1414+
},
14111415
],
14121416
},
14131417
{
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Expose Queues for local and self-hosted Supabase
3+
subtitle: Learn how to expose Queues when running Supabase with Supabase CLI or Docker Compose
4+
---
5+
6+
By default, local and self-hosted Supabase instances expose only core schemas like public and graphql_public.
7+
To allow client-side consumers to use your queues, you have to add `pgmq_public` schema to the list of exposed schemas.
8+
9+
Before continuing, complete the step [Expose queues to client-side consumers](/docs/guides/queues/quickstart#expose-queues-to-client-side-consumers) from the Queues Quickstart guide. This creates the `pgmq_public` schema, which must exist before it can be exposed through the API.
10+
11+
<Admonition type="note">
12+
13+
You only need to expose the `pgmq_public` schema manually when running Supabase locally with the Supabase CLI or self-hosting using Docker Compose.
14+
15+
</Admonition>
16+
17+
## Expose Queues with Supabase CLI
18+
19+
When running Supabase locally with Supabase CLI, update your project's `config.toml` file.
20+
Locate the `[api]` section and add `pgmq_public` to the list of schemas.
21+
22+
```toml
23+
[api]
24+
enabled = true
25+
port = 54321
26+
schemas = ["public", "graphql_public", "pgmq_public"]
27+
```
28+
29+
Then restart your local Supabase stack.
30+
31+
```bash
32+
supabase stop && supabase start
33+
```
34+
35+
## Expose queues with Docker compose
36+
37+
When running Supabase with Docker Compose, locate the `PGRST_DB_SCHEMAS` variable inside your `.env` file and add `pgmq_public` to it. This environment variable is passed to the `rest` service inside `docker-compose.yml`.
38+
39+
```
40+
PGRST_DB_SCHEMAS=public,graphql_public,pgmq_public
41+
```
42+
43+
Restart your containers for the changes to take effect.
44+
45+
```bash
46+
docker compose down
47+
docker compose up -d
48+
```
49+
50+
## Stop exposing queues
51+
52+
If you no longer want to expose the `pgmq_public` schema, you can remove it from your configuration.
53+
54+
- For Supabase CLI, remove `pgmq_public` from the `[api]` schemas list in your `config.toml` file.
55+
- For Docker Compose, remove `pgmq_public` from the `PGRST_DB_SCHEMAS` variable in your `.env` file.
56+
57+
After updating your configuration, restart your containers for the changes to take effect.

apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ import {
3131
FormField_Shadcn_,
3232
FormItem_Shadcn_,
3333
Switch,
34+
TextLink,
3435
} from 'ui'
3536
import { Admonition } from 'ui-patterns'
3637
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
3738
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
39+
import { IS_PLATFORM } from 'lib/constants'
3840

3941
// [Joshen] Not convinced with the UI and layout but getting the functionality out first
4042

@@ -86,18 +88,20 @@ export const QueuesSettings = () => {
8688

8789
const { mutateAsync: updateTable } = useTableUpdateMutation()
8890

91+
const onPostgrestConfigUpdateSuccess = () => {
92+
if (enable) {
93+
toast.success('Queues can now be managed through client libraries or PostgREST endpoints!')
94+
} else {
95+
toast.success(
96+
'Queues can no longer be managed through client libraries or PostgREST endpoints'
97+
)
98+
}
99+
setIsToggling(false)
100+
form.reset({ enable })
101+
}
102+
89103
const { mutate: updatePostgrestConfig } = useProjectPostgrestConfigUpdateMutation({
90-
onSuccess: () => {
91-
if (enable) {
92-
toast.success('Queues can now be managed through client libraries or PostgREST endpoints!')
93-
} else {
94-
toast.success(
95-
'Queues can no longer be managed through client libraries or PostgREST endpoints'
96-
)
97-
}
98-
setIsToggling(false)
99-
form.reset({ enable })
100-
},
104+
onSuccess: onPostgrestConfigUpdateSuccess,
101105
onError: (error) => {
102106
setIsToggling(false)
103107
toast.error(`Failed to toggle queue exposure via PostgREST: ${error.message}`)
@@ -106,6 +110,7 @@ export const QueuesSettings = () => {
106110

107111
const { mutate: toggleExposeQueuePostgrest } = useDatabaseQueueToggleExposeMutation({
108112
onSuccess: (_, values) => {
113+
if (!IS_PLATFORM) return onPostgrestConfigUpdateSuccess()
109114
if (project && config) {
110115
if (values.enable) {
111116
const updatedSchemas = schemas.concat([QUEUES_SCHEMA])
@@ -220,6 +225,20 @@ export const QueuesSettings = () => {
220225
<code className="text-xs">archive</code>, and{' '}
221226
<code className="text-xs">delete</code>
222227
</p>
228+
{!IS_PLATFORM ? (
229+
<div className="mt-6 max-w-2xl">
230+
When running Supabase locally with the CLI or self-hosting using
231+
Docker Compose, you also need to update your configuration to expose
232+
the <code className="text-xs">{QUEUES_SCHEMA}</code> schema.
233+
<br />
234+
<TextLink
235+
target="_blank"
236+
className="mt-0 inline-block"
237+
label="Learn more"
238+
url="https://supabase.com/docs/guides/queues/expose-self-hosted-queues"
239+
/>
240+
</div>
241+
) : null}
223242
</>
224243
}
225244
>

0 commit comments

Comments
 (0)