The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: pg_partman support for Queues through dashboard (#44359)
Ali Waseemfc65261bd4a4
diff --git a/apps/studio/components/interfaces/Database/Extensions/Extensions.constants.ts b/apps/studio/components/interfaces/Database/Extensions/Extensions.constants.tsindex 065adf1b7dc..0bb9c07e8f5 100644--- a/apps/studio/components/interfaces/Database/Extensions/Extensions.constants.ts+++ b/apps/studio/components/interfaces/Database/Extensions/Extensions.constants.ts@@ -19,10 +19,13 @@ export const HIDDEN_EXTENSIONS = [export const SEARCH_TERMS: Record<string, string[]> = {vector: ['pgvector', 'pg_vector'],+ pg_partman: ['partman', 'partition', 'partitioned'],}export const EXTENSION_DISABLE_WARNINGS: Record<string, string> = {pg_cron: 'Disabling this extension will delete all scheduled jobs. This cannot be undone.',+ pg_partman:+ 'Disabling this extension will stop automatic partition management for any partitioned queues. New partitions will no longer be created and retention policies will no longer be enforced.',}// Extensions that have recommended schemas (rather than required schemas)diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsxdeleted file mode 100644index b01387918a1..00000000000--- a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet.tsx+++ /dev/null@@ -1,329 +0,0 @@-import { zodResolver } from '@hookform/resolvers/zod'-import { SubmitHandler, useForm } from 'react-hook-form'-import { toast } from 'sonner'-import z from 'zod'--import { Markdown } from 'components/interfaces/Markdown'-import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'-import { useDatabaseQueueCreateMutation } from 'data/database-queues/database-queues-create-mutation'-import { useQueuesExposePostgrestStatusQuery } from 'data/database-queues/database-queues-expose-postgrest-status-query'-import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'-import { useConfirmOnClose } from 'hooks/ui/useConfirmOnClose'-import { useRouter } from 'next/router'-import { useEffect } from 'react'-import {- Badge,- Button,- Checkbox_Shadcn_,- Form_Shadcn_,- FormControl_Shadcn_,- FormField_Shadcn_,- Input,- Input_Shadcn_,- RadioGroupStacked,- RadioGroupStackedItem,- Separator,- Sheet,- SheetContent,- SheetFooter,- SheetHeader,- SheetSection,- SheetTitle,-} from 'ui'-import { Admonition } from 'ui-patterns'-import { DiscardChangesConfirmationDialog } from 'components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'-import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'-import { QUEUE_TYPES } from './Queues.constants'-import { QueryNameSchema } from './Queues.utils'--export interface CreateQueueSheetProps {- visible: boolean- onClose: () => void-}--const normalQueueSchema = z.object({- type: z.literal('basic'),-})--const partitionedQueueSchema = z.object({- type: z.literal('partitioned'),- partitionInterval: z.number(),- retentionInterval: z.number(),-})--const unloggedQueueSchema = z.object({- type: z.literal('unlogged'),-})--const FormSchema = z.object({- name: QueryNameSchema,- enableRls: z.boolean(),- values: z.discriminatedUnion('type', [- normalQueueSchema,- partitionedQueueSchema,- unloggedQueueSchema,- ]),-})--export type CreateQueueForm = z.infer<typeof FormSchema>-export type QueueType = CreateQueueForm['values']--const FORM_ID = 'create-queue-sidepanel'--export const CreateQueueSheet = ({ visible, onClose }: CreateQueueSheetProps) => {- const router = useRouter()- const { data: project } = useSelectedProjectQuery()-- const { data: isExposed } = useQueuesExposePostgrestStatusQuery({- projectRef: project?.ref,- connectionString: project?.connectionString,- })-- const { mutate: createQueue, isPending } = useDatabaseQueueCreateMutation()-- const form = useForm<CreateQueueForm>({- resolver: zodResolver(FormSchema),- defaultValues: {- name: '',- enableRls: true,- values: { type: 'basic' },- },- })-- useEffect(() => {- if (visible) {- form.reset()- }- }, [- form,- // end of stable references- visible,- ])-- const checkIsDirty = () => form.formState.isDirty-- const { confirmOnClose, handleOpenChange, modalProps } = useConfirmOnClose({- checkIsDirty,- onClose,- })-- const onSubmit: SubmitHandler<CreateQueueForm> = async ({ name, enableRls, values }) => {- createQueue(- {- projectRef: project!.ref,- connectionString: project?.connectionString,- name,- enableRls,- type: values.type,- configuration:- values.type === 'partitioned'- ? {- partitionInterval: values.partitionInterval,- retentionInterval: values.retentionInterval,- }- : undefined,- },- {- onSuccess: () => {- toast.success(`Successfully created queue ${name}`)- router.push(`/project/${project?.ref}/integrations/queues/queues/${name}`)- onClose()- },- }- )- }-- const { data } = useDatabaseExtensionsQuery({- projectRef: project?.ref,- connectionString: project?.connectionString,- })-- const pgPartmanExtension = (data ?? []).find((ext) => ext.name === 'pg_partman')- const pgPartmanExtensionInstalled = pgPartmanExtension?.installed_version != undefined-- const queueType = form.watch('values.type')-- return (- <Sheet open={visible} onOpenChange={handleOpenChange}>- <SheetContent size="default" className="w-[35%]" tabIndex={undefined}>- <div className="flex flex-col h-full" tabIndex={-1}>- <SheetHeader>- <SheetTitle>Create a new queue</SheetTitle>- </SheetHeader>-- <div className="overflow-auto flex-grow">- <Form_Shadcn_ {...form}>- <form- id={FORM_ID}- className="flex-grow overflow-auto"- onSubmit={form.handleSubmit(onSubmit)}- >- <SheetSection>- <FormField_Shadcn_- control={form.control}- name="name"- render={({ field }) => (- <FormItemLayout label="Name" layout="vertical" className="gap-1 relative">- <FormControl_Shadcn_>- <Input_Shadcn_ {...field} />- </FormControl_Shadcn_>- <span className="text-foreground-lighter text-xs absolute top-0 right-0">- Must be all lowercase letters- </span>- </FormItemLayout>- )}- />- </SheetSection>- <Separator />- <SheetSection>- <FormField_Shadcn_- control={form.control}- name="values.type"- render={({ field }) => (- <FormItemLayout label="Type" layout="vertical" className="gap-1">- <FormControl_Shadcn_>- <RadioGroupStacked- id="queue_type"- name="queue_type"- value={field.value}- disabled={field.disabled}- onValueChange={field.onChange}- >- {QUEUE_TYPES.map((definition) => (- <RadioGroupStackedItem- key={definition.value}- id={definition.value}- value={definition.value}- label=""- disabled={- !pgPartmanExtensionInstalled && definition.value === 'partitioned'- }- showIndicator={false}- >- <div className="flex items-start gap-x-5">- <div className="text-foreground">{definition.icon}</div>- <div className="flex flex-col gap-y-1">- <div className="flex items-center gap-x-2">- <p className="text-foreground text-left">- {definition.label}- </p>- {definition.value === 'partitioned' && (- <Badge>Coming soon</Badge>- )}- </div>- <p className="text-foreground-lighter text-left">- {definition.description}- </p>- </div>- </div>- </RadioGroupStackedItem>- ))}- </RadioGroupStacked>- </FormControl_Shadcn_>- </FormItemLayout>- )}- />- </SheetSection>- <Separator />- {queueType === 'partitioned' && (- <>- <SheetSection className="flex flex-col gap-3">- <FormField_Shadcn_- control={form.control}- name="values.partitionInterval"- render={({ field: { ref, ...rest } }) => (- <FormItemLayout label="Partition interval" className="gap-1">- <Input- {...rest}- type="number"- placeholder="1000"- actions={<p className="text-foreground-light pr-2">ms</p>}- />- </FormItemLayout>- )}- />- <FormField_Shadcn_- control={form.control}- name="values.retentionInterval"- render={({ field: { ref, ...rest } }) => (- <FormItemLayout label="Retention interval" className="gap-1">- <Input- {...rest}- type="number"- placeholder="1000"- actions={<p className="text-foreground-light pr-2">ms</p>}- />- </FormItemLayout>- )}- />- </SheetSection>- <Separator />- </>- )}- <SheetSection className="flex flex-col gap-y-2">- <FormField_Shadcn_- control={form.control}- name="enableRls"- render={({ field }) => (- <FormItemLayout- layout="flex"- label={- <div className="flex items-center gap-x-2">- <p>Enable Row Level Security (RLS)</p>- <Badge variant="success">Recommended</Badge>- </div>- }- description="Restrict access to your queue by enabling RLS and writing Postgres policies to control access for each role."- >- <FormControl_Shadcn_>- <Checkbox_Shadcn_- checked={field.value}- onCheckedChange={field.onChange}- disabled={field.disabled || isExposed}- />- </FormControl_Shadcn_>- </FormItemLayout>- )}- />- {!isExposed ? (- <Admonition- type="default"- title="Row Level Security for queues is only relevant if exposure through PostgREST has been enabled"- >- <Markdown- className="[&>p]:!leading-normal"- content={`You may opt to manage your queues via any Supabase client libraries or PostgREST- endpoints by enabling this in the [queues settings](/project/${project?.ref}/integrations/queues/settings).`}- />- </Admonition>- ) : (- <Admonition- type="default"- title="RLS must be enabled as queues are exposed via PostgREST"- description="This is to prevent anonymous access to any of your queues"- />- )}- </SheetSection>- </form>- </Form_Shadcn_>- </div>- <SheetFooter>- <Button- size="tiny"- type="default"- htmlType="button"- onClick={confirmOnClose}- disabled={isPending}- >- Cancel- </Button>- <Button size="tiny" type="primary" form={FORM_ID} htmlType="submit" loading={isPending}>- Create queue- </Button>- </SheetFooter>- </div>- <DiscardChangesConfirmationDialog {...modalProps} />- </SheetContent>- </Sheet>- )-}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.schema.ts b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.schema.tsnew file mode 100644index 00000000000..e4ff0c93fd0--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.schema.ts@@ -0,0 +1,30 @@+import z from 'zod'++import { QueryNameSchema } from '../Queues.utils'++const normalQueueSchema = z.object({+ type: z.literal('basic'),+})++const partitionedQueueSchema = z.object({+ type: z.literal('partitioned'),+ partitionInterval: z.coerce.number().int().positive(),+ retentionInterval: z.coerce.number().int().positive(),+})++const unloggedQueueSchema = z.object({+ type: z.literal('unlogged'),+})++export const FormSchema = z.object({+ name: QueryNameSchema,+ enableRls: z.boolean(),+ values: z.discriminatedUnion('type', [+ normalQueueSchema,+ partitionedQueueSchema,+ unloggedQueueSchema,+ ]),+})++export type CreateQueueForm = z.infer<typeof FormSchema>+export type QueueType = CreateQueueForm['values']diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.tsxnew file mode 100644index 00000000000..fe91f24310b--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/CreateQueueSheet.tsx@@ -0,0 +1,161 @@+import { zodResolver } from '@hookform/resolvers/zod'+import { DiscardChangesConfirmationDialog } from 'components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'+import { useDatabaseQueueCreateMutation } from 'data/database-queues/database-queues-create-mutation'+import { useQueuesExposePostgrestStatusQuery } from 'data/database-queues/database-queues-expose-postgrest-status-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { useConfirmOnClose } from 'hooks/ui/useConfirmOnClose'+import { useRouter } from 'next/router'+import { useEffect, useMemo } from 'react'+import { SubmitHandler, useForm } from 'react-hook-form'+import { toast } from 'sonner'+import {+ Button,+ Form_Shadcn_,+ Separator,+ Sheet,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from 'ui'++import { usePgPartmanStatus } from '../usePgPartmanStatus'+import { CreateQueueForm, FormSchema } from './CreateQueueSheet.schema'+import { PartitionConfigFields } from './PartitionConfigFields'+import { PgPartmanCallout } from './PgPartmanCallout'+import { QueueNameField } from './QueueNameField'+import { QueueTypeSelector } from './QueueTypeSelector'+import { RlsSection } from './RlsSection'++export interface CreateQueueSheetProps {+ visible: boolean+ onClose: () => void+}++const FORM_ID = 'create-queue-sidepanel'++export const CreateQueueSheet = ({ visible, onClose }: CreateQueueSheetProps) => {+ const router = useRouter()+ const { data: project } = useSelectedProjectQuery()++ const { data: isExposed } = useQueuesExposePostgrestStatusQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })++ const { mutate: createQueue, isPending } = useDatabaseQueueCreateMutation()+ const { isInstalled: pgPartmanInstalled } = usePgPartmanStatus()++ const defaultValues: CreateQueueForm = useMemo(+ () =>+ pgPartmanInstalled+ ? {+ name: '',+ enableRls: true,+ values: { type: 'partitioned', partitionInterval: 10000, retentionInterval: 100000 },+ }+ : { name: '', enableRls: true, values: { type: 'basic' } },+ [pgPartmanInstalled]+ )++ const form = useForm<CreateQueueForm>({+ resolver: zodResolver(FormSchema),+ defaultValues,+ })++ useEffect(() => {+ if (visible) {+ form.reset(defaultValues)+ }+ }, [form, defaultValues, visible])++ const checkIsDirty = () => form.formState.isDirty++ const { confirmOnClose, handleOpenChange, modalProps } = useConfirmOnClose({+ checkIsDirty,+ onClose,+ })++ const onSubmit: SubmitHandler<CreateQueueForm> = async ({ name, enableRls, values }) => {+ if (!project?.ref) {+ toast.error('Project not found')+ return+ }++ createQueue(+ {+ projectRef: project.ref,+ connectionString: project?.connectionString,+ name,+ enableRls,+ type: values.type,+ configuration:+ values.type === 'partitioned'+ ? {+ partitionInterval: values.partitionInterval,+ retentionInterval: values.retentionInterval,+ }+ : undefined,+ },+ {+ onSuccess: () => {+ toast.success(`Successfully created queue ${name}`)+ router.push(`/project/${project?.ref}/integrations/queues/queues/${name}`)+ onClose()+ },+ }+ )+ }++ return (+ <Sheet open={visible} onOpenChange={handleOpenChange}>+ <SheetContent size="default" className="w-[35%]" tabIndex={undefined}>+ <div className="flex flex-col h-full" tabIndex={-1}>+ <SheetHeader>+ <SheetTitle>Create a new queue</SheetTitle>+ </SheetHeader>++ <div className="overflow-auto flex-grow">+ <Form_Shadcn_ {...form}>+ <form+ id={FORM_ID}+ className="flex-grow overflow-auto"+ onSubmit={form.handleSubmit(onSubmit)}+ >+ <QueueNameField form={form} />+ <Separator />+ <PgPartmanCallout />+ <QueueTypeSelector form={form} />+ <Separator />+ <PartitionConfigFields form={form} />+ <RlsSection form={form} isExposed={isExposed} projectRef={project?.ref} />+ </form>+ </Form_Shadcn_>+ </div>+ <SheetFooter>+ <Button+ size="tiny"+ type="default"+ htmlType="button"+ onClick={confirmOnClose}+ disabled={isPending}+ >+ Cancel+ </Button>+ <Button+ size="tiny"+ type="primary"+ form={FORM_ID}+ htmlType="submit"+ loading={isPending}+ disabled={!project?.ref}+ >+ Create queue+ </Button>+ </SheetFooter>+ </div>+ <DiscardChangesConfirmationDialog {...modalProps} />+ </SheetContent>+ </Sheet>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PartitionConfigFields.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PartitionConfigFields.tsxnew file mode 100644index 00000000000..e8dd8b87c58--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PartitionConfigFields.tsx@@ -0,0 +1,55 @@+import { UseFormReturn } from 'react-hook-form'+import { FormField_Shadcn_, Input, Separator, SheetSection } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++import { CreateQueueForm } from './CreateQueueSheet.schema'++export function PartitionConfigFields({ form }: { form: UseFormReturn<CreateQueueForm> }) {+ const queueType = form.watch('values.type')++ if (queueType !== 'partitioned') return null++ return (+ <>+ <SheetSection className="flex flex-col gap-3">+ <FormField_Shadcn_+ control={form.control}+ name="values.partitionInterval"+ render={({ field: { ref, ...rest } }) => (+ <FormItemLayout+ label="Partition interval"+ description="Number of messages per partition"+ className="gap-1"+ >+ <Input+ {...rest}+ type="number"+ placeholder="10000"+ actions={<p className="text-foreground-light pr-2">messages</p>}+ />+ </FormItemLayout>+ )}+ />+ <FormField_Shadcn_+ control={form.control}+ name="values.retentionInterval"+ render={({ field: { ref, ...rest } }) => (+ <FormItemLayout+ label="Retention interval"+ description="Partitions older than this many messages behind the latest will be dropped"+ className="gap-1"+ >+ <Input+ {...rest}+ type="number"+ placeholder="100000"+ actions={<p className="text-foreground-light pr-2">messages</p>}+ />+ </FormItemLayout>+ )}+ />+ </SheetSection>+ <Separator />+ </>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PgPartmanCallout.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PgPartmanCallout.tsxnew file mode 100644index 00000000000..4e7e54f35d8--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/PgPartmanCallout.tsx@@ -0,0 +1,39 @@+import { EnableExtensionModal } from 'components/interfaces/Database/Extensions/EnableExtensionModal'+import { useState } from 'react'+import { Button } from 'ui'+import { Admonition } from 'ui-patterns'++import { usePgPartmanStatus } from '../usePgPartmanStatus'++export function PgPartmanCallout() {+ const { pgPartmanExtension, isAvailable, isInstalled } = usePgPartmanStatus()+ const [showEnableModal, setShowEnableModal] = useState(false)++ if (!isAvailable || isInstalled) return null++ return (+ <div className="mx-5 my-2">+ <Admonition+ type="tip"+ title="pg_partman is now available"+ description="Unlock partitioned queues for automatic data retention, lower storage costs, and faster performance at scale."+ >+ <Button+ type="default"+ size="tiny"+ className="mt-2"+ onClick={() => setShowEnableModal(true)}+ >+ Enable pg_partman+ </Button>+ </Admonition>+ {pgPartmanExtension && (+ <EnableExtensionModal+ visible={showEnableModal}+ extension={pgPartmanExtension}+ onCancel={() => setShowEnableModal(false)}+ />+ )}+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueNameField.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueNameField.tsxnew file mode 100644index 00000000000..63811eced62--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueNameField.tsx@@ -0,0 +1,26 @@+import { UseFormReturn } from 'react-hook-form'+import { FormControl_Shadcn_, FormField_Shadcn_, Input_Shadcn_, SheetSection } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++import { CreateQueueForm } from './CreateQueueSheet.schema'++export function QueueNameField({ form }: { form: UseFormReturn<CreateQueueForm> }) {+ return (+ <SheetSection>+ <FormField_Shadcn_+ control={form.control}+ name="name"+ render={({ field }) => (+ <FormItemLayout label="Name" layout="vertical" className="gap-1 relative">+ <FormControl_Shadcn_>+ <Input_Shadcn_ {...field} />+ </FormControl_Shadcn_>+ <span className="text-foreground-lighter text-xs absolute top-0 right-0">+ Can include letters, numbers, underscores, and hyphens+ </span>+ </FormItemLayout>+ )}+ />+ </SheetSection>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueTypeSelector.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueTypeSelector.tsxnew file mode 100644index 00000000000..2af655d10f4--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/QueueTypeSelector.tsx@@ -0,0 +1,71 @@+import { UseFormReturn } from 'react-hook-form'+import {+ Badge,+ FormControl_Shadcn_,+ FormField_Shadcn_,+ RadioGroupStacked,+ RadioGroupStackedItem,+ SheetSection,+} from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++import { QUEUE_TYPES } from '../Queues.constants'+import { usePgPartmanStatus } from '../usePgPartmanStatus'+import { CreateQueueForm } from './CreateQueueSheet.schema'++export function QueueTypeSelector({ form }: { form: UseFormReturn<CreateQueueForm> }) {+ const { isInstalled } = usePgPartmanStatus()++ return (+ <SheetSection>+ <FormField_Shadcn_+ control={form.control}+ name="values.type"+ render={({ field }) => (+ <FormItemLayout label="Type" layout="vertical" className="gap-1">+ <FormControl_Shadcn_>+ <RadioGroupStacked+ id="queue_type"+ name="queue_type"+ value={field.value}+ disabled={field.disabled}+ onValueChange={field.onChange}+ >+ {QUEUE_TYPES.filter(+ (definition) => definition.value !== 'partitioned' || isInstalled+ ).map((definition) => {+ const isPartitioned = definition.value === 'partitioned'++ return (+ <RadioGroupStackedItem+ key={definition.value}+ id={definition.value}+ value={definition.value}+ label=""+ showIndicator={false}+ >+ <div className="flex items-start gap-x-5">+ <div className="text-foreground">{definition.icon}</div>+ <div className="flex flex-col gap-y-1">+ <div className="flex items-center gap-x-2">+ <p className="text-foreground text-left">{definition.label}</p>+ {isPartitioned && <Badge variant="success">Recommended</Badge>}+ </div>+ <p className="text-foreground-lighter text-left">+ {isPartitioned+ ? 'Automatically manages data retention and improves performance for high-volume queues via pg_partman.'+ : definition.description}+ </p>+ </div>+ </div>+ </RadioGroupStackedItem>+ )+ })}+ </RadioGroupStacked>+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </SheetSection>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/RlsSection.tsx b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/RlsSection.tsxnew file mode 100644index 00000000000..09f465e983f--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/RlsSection.tsx@@ -0,0 +1,64 @@+import { Markdown } from 'components/interfaces/Markdown'+import { UseFormReturn } from 'react-hook-form'+import { Badge, FormControl_Shadcn_, FormField_Shadcn_, SheetSection, Switch } from 'ui'+import { Admonition } from 'ui-patterns'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++import { CreateQueueForm } from './CreateQueueSheet.schema'++export function RlsSection({+ form,+ isExposed,+ projectRef,+}: {+ form: UseFormReturn<CreateQueueForm>+ isExposed: boolean | undefined+ projectRef: string | undefined+}) {+ return (+ <SheetSection className="flex flex-col gap-y-2">+ <FormField_Shadcn_+ control={form.control}+ name="enableRls"+ render={({ field }) => (+ <FormItemLayout+ layout="flex"+ label={+ <div className="flex items-center gap-x-2">+ <p>Enable Row Level Security (RLS)</p>+ <Badge variant="success">Recommended</Badge>+ </div>+ }+ description="Restrict access to your queue by enabling RLS and writing Postgres policies to control access for each role."+ >+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ disabled={field.disabled || isExposed}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ {!isExposed ? (+ <Admonition+ type="default"+ title="Row Level Security for queues is only relevant if exposure through PostgREST has been enabled"+ >+ <Markdown+ className="[&>p]:!leading-normal"+ content={`You may opt to manage your queues via any Supabase client libraries or PostgREST+ endpoints by enabling this in the [queues settings](/project/${projectRef}/integrations/queues/settings).`}+ />+ </Admonition>+ ) : (+ <Admonition+ type="default"+ title="RLS must be enabled as queues are exposed via PostgREST"+ description="This is to prevent anonymous access to any of your queues"+ />+ )}+ </SheetSection>+ )+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/index.ts b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/index.tsnew file mode 100644index 00000000000..7ce513a3e00--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/CreateQueueSheet/index.ts@@ -0,0 +1,3 @@+export { CreateQueueSheet } from './CreateQueueSheet'+export type { CreateQueueSheetProps } from './CreateQueueSheet'+export type { CreateQueueForm, QueueType } from './CreateQueueSheet.schema'diff --git a/apps/studio/components/interfaces/Integrations/Queues/usePgPartmanStatus.ts b/apps/studio/components/interfaces/Integrations/Queues/usePgPartmanStatus.tsnew file mode 100644index 00000000000..22d2aaf6dfb--- /dev/null+++ b/apps/studio/components/interfaces/Integrations/Queues/usePgPartmanStatus.ts@@ -0,0 +1,17 @@+import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'++export function usePgPartmanStatus() {+ const { data: project } = useSelectedProjectQuery()++ const { data: extensions } = useDatabaseExtensionsQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })++ const pgPartmanExtension = (extensions ?? []).find((ext) => ext.name === 'pg_partman')+ const isAvailable = pgPartmanExtension !== undefined+ const isInstalled = pgPartmanExtension?.installed_version != undefined++ return { pgPartmanExtension, isAvailable, isInstalled }+}diff --git a/packages/shared-data/extensions.json b/packages/shared-data/extensions.jsonindex b937f861509..b2788fabaea 100644--- a/packages/shared-data/extensions.json+++ b/packages/shared-data/extensions.json@@ -282,7 +282,7 @@"name": "pg_partman","comment": "Automated partition management","tags": ["Utility"],- "link": "/guides/database/extensions/pg_partman",+ "link": "https://github.com/pgpartman/pg_partman","github_url": "https://github.com/pgpartman/pg_partman","product": null,"product_url": null