The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(QueuesSettings): skip PostgREST config update for self-hosted projects (#40078)
Inder Singhf2a0139a2c81
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex b00b3698b5d..6078c6ae7b5 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -1408,6 +1408,10 @@ export const queues: NavMenuConstant = {name: 'Consuming Messages with Edge Functions',url: '/guides/queues/consuming-messages-with-edge-functions',},+ {+ name: 'Expose Queues for local and self-hosted Supabase',+ url: '/guides/queues/expose-self-hosted-queues',+ },],},{diff --git a/apps/docs/content/guides/queues/expose-self-hosted-queues.mdx b/apps/docs/content/guides/queues/expose-self-hosted-queues.mdxnew file mode 100644index 00000000000..dca20a998e0--- /dev/null+++ b/apps/docs/content/guides/queues/expose-self-hosted-queues.mdx@@ -0,0 +1,57 @@+---+title: Expose Queues for local and self-hosted Supabase+subtitle: Learn how to expose Queues when running Supabase with Supabase CLI or Docker Compose+---++By default, local and self-hosted Supabase instances expose only core schemas like public and graphql_public.+To allow client-side consumers to use your queues, you have to add `pgmq_public` schema to the list of exposed schemas.++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.++<Admonition type="note">++You only need to expose the `pgmq_public` schema manually when running Supabase locally with the Supabase CLI or self-hosting using Docker Compose.++</Admonition>++## Expose Queues with Supabase CLI++When running Supabase locally with Supabase CLI, update your project's `config.toml` file.+Locate the `[api]` section and add `pgmq_public` to the list of schemas.++```toml+[api]+enabled = true+port = 54321+schemas = ["public", "graphql_public", "pgmq_public"]+```++Then restart your local Supabase stack.++```bash+supabase stop && supabase start+```++## Expose queues with Docker compose++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`.++```+PGRST_DB_SCHEMAS=public,graphql_public,pgmq_public+```++Restart your containers for the changes to take effect.++```bash+docker compose down+docker compose up -d+```++## Stop exposing queues++If you no longer want to expose the `pgmq_public` schema, you can remove it from your configuration.++- For Supabase CLI, remove `pgmq_public` from the `[api]` schemas list in your `config.toml` file.+- For Docker Compose, remove `pgmq_public` from the `PGRST_DB_SCHEMAS` variable in your `.env` file.++After updating your configuration, restart your containers for the changes to take effect.diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsxindex a50b127c2d5..84aa3e82fb0 100644--- a/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx+++ b/apps/studio/components/interfaces/Integrations/Queues/QueuesSettings.tsx@@ -31,10 +31,12 @@ import {FormField_Shadcn_,FormItem_Shadcn_,Switch,+ TextLink,} from 'ui'import { Admonition } from 'ui-patterns'import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'+import { IS_PLATFORM } from 'lib/constants'// [Joshen] Not convinced with the UI and layout but getting the functionality out first@@ -86,18 +88,20 @@ export const QueuesSettings = () => {const { mutateAsync: updateTable } = useTableUpdateMutation()+ const onPostgrestConfigUpdateSuccess = () => {+ if (enable) {+ toast.success('Queues can now be managed through client libraries or PostgREST endpoints!')+ } else {+ toast.success(+ 'Queues can no longer be managed through client libraries or PostgREST endpoints'+ )+ }+ setIsToggling(false)+ form.reset({ enable })+ }+const { mutate: updatePostgrestConfig } = useProjectPostgrestConfigUpdateMutation({- onSuccess: () => {- if (enable) {- toast.success('Queues can now be managed through client libraries or PostgREST endpoints!')- } else {- toast.success(- 'Queues can no longer be managed through client libraries or PostgREST endpoints'- )- }- setIsToggling(false)- form.reset({ enable })- },+ onSuccess: onPostgrestConfigUpdateSuccess,onError: (error) => {setIsToggling(false)toast.error(`Failed to toggle queue exposure via PostgREST: ${error.message}`)@@ -106,6 +110,7 @@ export const QueuesSettings = () => {const { mutate: toggleExposeQueuePostgrest } = useDatabaseQueueToggleExposeMutation({onSuccess: (_, values) => {+ if (!IS_PLATFORM) return onPostgrestConfigUpdateSuccess()if (project && config) {if (values.enable) {const updatedSchemas = schemas.concat([QUEUES_SCHEMA])@@ -220,6 +225,20 @@ export const QueuesSettings = () => {<code className="text-xs">archive</code>, and{' '}<code className="text-xs">delete</code></p>+ {!IS_PLATFORM ? (+ <div className="mt-6 max-w-2xl">+ When running Supabase locally with the CLI or self-hosting using+ Docker Compose, you also need to update your configuration to expose+ the <code className="text-xs">{QUEUES_SCHEMA}</code> schema.+ <br />+ <TextLink+ target="_blank"+ className="mt-0 inline-block"+ label="Learn more"+ url="https://supabase.com/docs/guides/queues/expose-self-hosted-queues"+ />+ </div>+ ) : null}</>}>