为本地和自托管的 Supabase 暴露队列
Learn how to expose Queues when running Supabase with Supabase CLI or Docker Compose
默认情况下,本地和自托管的 Supabase 实例只会公开核心 schema,比如 public 和 graphql_public。要让客户端使用你的队列,你需要把 pgmq_public schema 添加到公开的 schema 列表中。
🌐 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.
在继续之前,请完成队列快速入门指南中的步骤 向客户端消费者公开队列。这会创建 pgmq_public 架构,该架构必须存在,才能通过 API 暴露。
🌐 Before continuing, complete the step 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.
当你在本地使用 Supabase CLI 运行 Supabase 或使用 Docker Compose 自行托管时,你只需要手动暴露 pgmq_public 模式。
🌐 You only need to expose the pgmq_public schema manually when running Supabase locally with the Supabase CLI or self-hosting using Docker Compose.
使用 Supabase CLI 暴露队列 #
🌐 Expose Queues with Supabase CLI
在本地使用 Supabase CLI 运行 Supabase 时,更新你项目的 config.toml 文件。找到 [api] 部分,并将 pgmq_public 添加到 schema 列表中。
🌐 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.
1[api]2enabled = true3port = 543214schemas = ["public", "graphql_public", "pgmq_public"]然后重启你本地的 Supabase 堆栈。
🌐 Then restart your local Supabase stack.
1supabase stop && supabase start用 Docker Compose 暴露队列 #
🌐 Expose queues with Docker compose
在用 Docker Compose 运行 Supabase 时,找到你 .env 文件里的 PGRST_DB_SCHEMAS 变量,然后向它添加 pgmq_public。这个环境变量会传递给 docker-compose.yml 里的 rest 服务。
🌐 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.
1PGRST_DB_SCHEMAS=public,graphql_public,pgmq_public重启你的容器以使更改生效。
🌐 Restart your containers for the changes to take effect.
1docker compose down2docker compose up -d别再暴露队列了 #
🌐 Stop exposing queues
如果你不想再公开 pgmq_public 模式,你可以把它从配置中移除。
🌐 If you no longer want to expose the pgmq_public schema, you can remove it from your configuration.
- 对于 Supabase CLI,从你的
config.toml文件中的[api]架构列表里移除pgmq_public。 - 对于 Docker Compose,在你的
.env文件中从PGRST_DB_SCHEMAS变量中移除pgmq_public。
在更新配置后,重启你的容器让更改生效。
🌐 After updating your configuration, restart your containers for the changes to take effect.