Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

[FE-3790] fix(studio): hide Multigres from user-facing surfaces (#48191)

Alaister Young0fe236665905
diff --git a/apps/studio/components/interfaces/Database/Extensions/EnableExtensionModal.tsx b/apps/studio/components/interfaces/Database/Extensions/EnableExtensionModal.tsx
index e9c36ea6bca..5e63927a2eb 100644
--- a/apps/studio/components/interfaces/Database/Extensions/EnableExtensionModal.tsx
+++ b/apps/studio/components/interfaces/Database/Extensions/EnableExtensionModal.tsx
@@ -1,4 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod'
+import { useMemo } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import {
@@ -32,6 +33,7 @@ import { DocsButton } from '@/components/ui/DocsButton'
import { useDatabaseExtensionEnableMutation } from '@/data/database-extensions/database-extension-enable-mutation'
import { type DatabaseExtension } from '@/data/database-extensions/database-extensions-query'
import { useSchemasQuery } from '@/data/database/schemas-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
import { DOCS_URL } from '@/lib/constants'
@@ -72,10 +74,15 @@ export const EnableExtensionModal = ({
},
{ enabled: visible }
)
- const availableSchemas = schemas.filter(
- (schema) =>
- schema.name === recommendedSchema ||
- !protectedSchemas.some((protectedSchema) => protectedSchema.name === schema.name)
+ const visibleSchemas = useSchemasFilteredForHighAvailability(schemas)
+ const availableSchemas = useMemo(
+ () =>
+ visibleSchemas.filter(
+ (schema) =>
+ schema.name === recommendedSchema ||
+ !protectedSchemas.some((protectedSchema) => protectedSchema.name === schema.name)
+ ),
+ [visibleSchemas, recommendedSchema, protectedSchemas]
)
// [Joshen] Hard-coding pg_cron here as this is enforced on our end (Not via pg_available_extension_versions)
diff --git a/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx b/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
index 1e5a3657258..f563566b069 100644
--- a/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
+++ b/apps/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
@@ -52,6 +52,7 @@ import { useDatabaseIndexCreateMutation } from '@/data/database-indexes/index-cr
import { useSchemasQuery } from '@/data/database/schemas-query'
import { useTableColumnsQuery } from '@/data/database/table-columns-query'
import { useEntityTypesQuery } from '@/data/entity-types/entity-types-infinite-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
@@ -98,10 +99,11 @@ export const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelP
const [schemaSearchTerm, setSchemaSearchTerm] = useState('')
const [searchTerm, setSearchTerm] = useState('')
- const { data: schemas } = useSchemasQuery({
+ const { data: allSchemas } = useSchemasQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
+ const schemas = useSchemasFilteredForHighAvailability(allSchemas)
const { data: entities, isPending: isLoadingEntities } = useEntityTypesQuery({
schemas: [selectedSchema],
sort: 'alphabetical',
diff --git a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/AdvancedSettings.tsx b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/AdvancedSettings.tsx
index 8913a641fe7..a488cf484c9 100644
--- a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/AdvancedSettings.tsx
+++ b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/AdvancedSettings.tsx
@@ -1,4 +1,4 @@
-import { type Dispatch, type SetStateAction } from 'react'
+import { useMemo, type Dispatch, type SetStateAction } from 'react'
import {
Accordion,
AccordionContent,
@@ -21,6 +21,7 @@ import { type ExtensionsSchema, type InstallIntegrationSheetProps } from './Inst
import { extensionsWithRecommendedSchemas } from '@/components/interfaces/Database/Extensions/Extensions.constants'
import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query'
import { useSchemasQuery } from '@/data/database/schemas-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
@@ -48,8 +49,14 @@ export const AdvancedSettings = ({
{ projectRef: project?.ref, connectionString: project?.connectionString },
{ enabled: involvesExtensions }
)
- const availableSchemas = schemas.filter(
- (schema) => !protectedSchemas.some((protectedSchema) => protectedSchema.name === schema.name)
+ const visibleSchemas = useSchemasFilteredForHighAvailability(schemas)
+ const availableSchemas = useMemo(
+ () =>
+ visibleSchemas.filter(
+ (schema) =>
+ !protectedSchemas.some((protectedSchema) => protectedSchema.name === schema.name)
+ ),
+ [visibleSchemas, protectedSchemas]
)
return (
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx
index bb0b6c67e27..c052e9551c2 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTableEditor.tsx
@@ -51,6 +51,7 @@ import type { AvailableColumn, Table, TableOption } from './Wrappers.types'
import { getTableFormSchema } from './Wrappers.utils'
import { ActionBar } from '@/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar'
import { useSchemasQuery } from '@/data/database/schemas-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
export type WrapperTableEditorProps = {
@@ -239,10 +240,11 @@ const TableForm = ({
initialData: any
}) => {
const { data: project } = useSelectedProjectQuery()
- const { data: schemas, isPending: isLoading } = useSchemasQuery({
+ const { data: allSchemas, isPending: isLoading } = useSchemasQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
+ const schemas = useSchemasFilteredForHighAvailability(allSchemas)
const requiredOptions: TableOption[] = []
const optionalOptions: TableOption[] = []
diff --git a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
index 4e8dc59171c..5e24360fa55 100644
--- a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx
@@ -1,4 +1,3 @@
-import Link from 'next/link'
import { UseFormReturn } from 'react-hook-form'
import { FormControl, FormField, Switch } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
@@ -22,16 +21,7 @@ export const HighAvailabilityInput = ({ form }: HighAvailabilityInputProps) => {
render={({ field }) => (
<FormItemLayout
label="High Availability"
- description={
- <>
- Powered by{' '}
- <Link href="https://multigres.com/" target="_blank" className="text-link">
- Multigres
- </Link>
- : horizontally scalable Postgres for multi-tenant, highly available, globally
- distributed deployments while staying true to standard Postgres.
- </>
- }
+ description="Horizontally scalable Postgres for highly available, globally distributed deployments while staying true to standard Postgres."
layout="horizontal"
>
<FormControl>
diff --git a/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx b/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
index 48c1d50d7f3..15041a5c3c5 100644
--- a/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
+++ b/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
@@ -33,9 +33,8 @@ export function HighAvailabilityBadge({ size = 'default' }: HighAvailabilityBadg
<Separator />
<div className="flex flex-col gap-1 p-3 px-5">
<p className="text-sm text-foreground-light">
- Driven by <span className="text-foreground">Multigres</span>, a horizontally scalable
- Postgres architecture that supports highly-available and globally distributed
- deployments.
+ A horizontally scalable Postgres architecture that supports highly-available and
+ globally distributed deployments.
</p>
<Link
href={`${DOCS_URL}/guides/deployment/high-availability`}
diff --git a/apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts b/apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts
index f3a0ceabbc9..a55817590c8 100644
--- a/apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts
+++ b/apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts
@@ -9,6 +9,7 @@ import { useDatabaseFunctionsQuery } from '@/data/database-functions/database-fu
import { useKeywordsQuery } from '@/data/database/keywords-query'
import { useSchemasQuery } from '@/data/database/schemas-query'
import { useTableColumnsQuery } from '@/data/database/table-columns-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { formatSql } from '@/lib/formatSql'
@@ -54,6 +55,8 @@ export const useAddDefinitions = (id: string, monaco: Monaco | null) => {
const pgInfoRef = useRef<any>(null)
+ const filteredSchemas = useSchemasFilteredForHighAvailability(schemas)
+
const isPgInfoReady =
intellisenseEnabled &&
isTableColumnsSuccess &&
@@ -66,7 +69,7 @@ export const useAddDefinitions = (id: string, monaco: Monaco | null) => {
pgInfoRef.current = {}
}
pgInfoRef.current.tableColumns = tableColumns
- pgInfoRef.current.schemas = schemas
+ pgInfoRef.current.schemas = filteredSchemas
pgInfoRef.current.keywords = keywords
pgInfoRef.current.functions = functions
}
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
index dff0cfdd0af..c21b8c8826f 100644
--- a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
+++ b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
@@ -18,6 +18,11 @@ import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { getExposedSchemaCounts } from './ExposedSchemaSelector.utils'
import { useSchemasQuery } from '@/data/database/schemas-query'
+import {
+ MULTIGRES_SCHEMA_NAME,
+ useHighAvailability,
+ useSchemasFilteredForHighAvailability,
+} from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { INTERNAL_SCHEMAS } from '@/hooks/useProtectedSchemas'
import { pluralize } from '@/lib/helpers'
@@ -48,6 +53,7 @@ export const ExposedSchemaSelector = ({
const [open, setOpen] = useState(false)
const { data: project } = useSelectedProjectQuery()
+ const { isHighAvailability } = useHighAvailability()
const {
data: allSchemas,
@@ -59,23 +65,34 @@ export const ExposedSchemaSelector = ({
connectionString: project?.connectionString,
})
+ const visibleSchemas = useSchemasFilteredForHighAvailability(allSchemas)
const schemas = useMemo(
() =>
- (allSchemas ?? [])
+ visibleSchemas
.filter((s) => !internalSchemasCannotExpose.has(s.name))
.sort((a, b) => a.name.localeCompare(b.name)),
- [allSchemas]
+ [visibleSchemas]
+ )
+
+ // Persisted selections go through the same HA filtering as the schema list, so a
+ // multigres schema exposed in the config doesn't render as a "missing" schema row.
+ const visibleSelectedSchemas = useMemo(
+ () =>
+ isHighAvailability
+ ? selectedSchemas.filter((schema) => schema !== MULTIGRES_SCHEMA_NAME)
+ : selectedSchemas,
+ [selectedSchemas, isHighAvailability]
)
const missingExposedSchema = useMemo(
- () => selectedSchemas.filter((schema) => !schemas.some((s) => s.name === schema)),
- [schemas, selectedSchemas]
+ () => visibleSelectedSchemas.filter((schema) => !schemas.some((s) => s.name === schema)),
+ [schemas, visibleSelectedSchemas]
)
- const selectedSet = useMemo(() => new Set(selectedSchemas), [selectedSchemas])
+ const selectedSet = useMemo(() => new Set(visibleSelectedSchemas), [visibleSelectedSchemas])
const { selectedCount, totalCount } = getExposedSchemaCounts({
visibleSchemas: schemas.map((s) => s.name),
- selectedSchemas,
+ selectedSchemas: visibleSelectedSchemas,
protectedSchemas: internalSchemasCannotExpose,
})
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
index 596a20b1937..41a07a75d81 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
@@ -2,7 +2,7 @@ import { FOREIGN_KEY_CASCADE_ACTION } from '@supabase/pg-meta'
import type { PGTable } from '@supabase/pg-meta'
import { sortBy } from 'lodash'
import { ArrowRight, HelpCircle, Loader2, X } from 'lucide-react'
-import { Fragment, useEffect, useState } from 'react'
+import { Fragment, useEffect, useMemo, useState } from 'react'
import {
Alert,
AlertDescription,
@@ -34,6 +34,7 @@ import InformationBox from '@/components/ui/InformationBox'
import { useSchemasQuery } from '@/data/database/schemas-query'
import { useTableQuery } from '@/data/tables/table-retrieve-query'
import { useTablesQuery } from '@/data/tables/tables-query'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useQuerySchemaState } from '@/hooks/misc/useSchemaQueryState'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'
@@ -89,7 +90,11 @@ export const ForeignKeySelector = ({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
- const sortedSchemas = [...schemas].sort((a, b) => a.name.localeCompare(b.name))
+ const visibleSchemas = useSchemasFilteredForHighAvailability(schemas)
+ const sortedSchemas = useMemo(
+ () => [...visibleSchemas].sort((a, b) => a.name.localeCompare(b.name)),
+ [visibleSchemas]
+ )
const { data: tables } = useTablesQuery({
projectRef: project?.ref,
diff --git a/apps/studio/components/ui/SchemaSelector.test.tsx b/apps/studio/components/ui/SchemaSelector.test.tsx
new file mode 100644
index 00000000000..0cff282ba8b
--- /dev/null
+++ b/apps/studio/components/ui/SchemaSelector.test.tsx
@@ -0,0 +1,69 @@
+import { screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { mockAnimationsApi } from 'jsdom-testing-mocks'
+import { HttpResponse } from 'msw'
+import { describe, expect, it, vi } from 'vitest'
+
+import { SchemaSelector } from './SchemaSelector'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock } from '@/tests/lib/msw'
+
+mockAnimationsApi()
+
+const mockProjectAndSchemas = ({ highAvailability }: { highAvailability: boolean }) => {
+ // useSelectedProjectQuery
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref',
+ // @ts-expect-error partial project response
+ response: {
+ cloud_provider: 'localhost',
+ id: 1,
+ inserted_at: '2021-08-02T06:40:40.646Z',
+ name: 'Default Project',
+ organization_id: 1,
+ ref: 'default',
+ region: 'local',
+ status: 'ACTIVE_HEALTHY',
+ high_availability: highAvailability,
+ },
+ })
+ // useSchemasQuery (schemas list SQL via pg-meta)
+ addAPIMock({
+ method: 'post',
+ path: '/platform/pg-meta/:ref/query',
+ response: () =>
+ HttpResponse.json([
+ { id: 1, name: 'public' },
+ { id: 2, name: 'multigres' },
+ { id: 3, name: 'other' },
+ ]),
+ })
+}
+
+const renderAndOpenSelector = async () => {
+ customRender(<SchemaSelector selectedSchemaName="public" onSelectSchema={vi.fn()} />)
+
+ await userEvent.click(await screen.findByTestId('schema-selector'))
+ // Wait for the list to be populated before asserting absence
+ await screen.findByRole('option', { name: 'public' })
+}
+
+describe('SchemaSelector', () => {
+ it('hides the multigres schema on high availability projects', async () => {
+ mockProjectAndSchemas({ highAvailability: true })
+
+ await renderAndOpenSelector()
+
+ expect(screen.getByRole('option', { name: 'other' })).toBeInTheDocument()
+ expect(screen.queryByRole('option', { name: 'multigres' })).not.toBeInTheDocument()
+ })
+
+ it('shows the multigres schema on non high availability projects', async () => {
+ mockProjectAndSchemas({ highAvailability: false })
+
+ await renderAndOpenSelector()
+
+ expect(screen.getByRole('option', { name: 'multigres' })).toBeInTheDocument()
+ })
+})
diff --git a/apps/studio/components/ui/SchemaSelector.tsx b/apps/studio/components/ui/SchemaSelector.tsx
index a04328e0367..a051ce4c6f4 100644
--- a/apps/studio/components/ui/SchemaSelector.tsx
+++ b/apps/studio/components/ui/SchemaSelector.tsx
@@ -1,6 +1,6 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { Check, ChevronsUpDown, Plus } from 'lucide-react'
-import { ComponentPropsWithoutRef, forwardRef, useState } from 'react'
+import { ComponentPropsWithoutRef, forwardRef, useMemo, useState } from 'react'
import {
Alert,
AlertDescription,
@@ -22,6 +22,7 @@ import {
import { useSchemasQuery } from '@/data/database/schemas-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
type SchemaSelectorProps = Omit<ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
@@ -40,6 +41,8 @@ type SchemaSelectorProps = Omit<ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
onOpenChange?: (open: boolean) => void
}
+const DEFAULT_EXCLUDED_SCHEMAS: string[] = []
+
export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(
(
{
@@ -50,7 +53,7 @@ export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(
selectedSchemaName,
placeholderLabel = 'Choose a schema...',
supportSelectAll = false,
- excludedSchemas = [],
+ excludedSchemas = DEFAULT_EXCLUDED_SCHEMAS,
stopScrollPropagation = false,
onSelectSchema,
onSelectCreateSchema,
@@ -86,9 +89,15 @@ export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(
connectionString: project?.connectionString,
})
- const schemas = (data || [])
- .filter((schema) => !excludedSchemas.includes(schema.name))
- .sort((a, b) => a.name.localeCompare(b.name))
+ const visibleSchemas = useSchemasFilteredForHighAvailability(data)
+
+ const schemas = useMemo(
+ () =>
+ visibleSchemas
+ .filter((schema) => !excludedSchemas.includes(schema.name))
+ .sort((a, b) => a.name.localeCompare(b.name)),
+ [visibleSchemas, excludedSchemas]
+ )
return (
<div ref={ref} className={className} {...rest}>
diff --git a/apps/studio/hooks/misc/__tests__/useHighAvailability.test.ts b/apps/studio/hooks/misc/__tests__/useHighAvailability.test.ts
new file mode 100644
index 00000000000..5a78143bd27
--- /dev/null
+++ b/apps/studio/hooks/misc/__tests__/useHighAvailability.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from 'vitest'
+
+import { filterSchemasForHighAvailability } from '../useHighAvailability'
+import { MULTIGRES_SCHEMA_NAME, resolveHighAvailability } from '../useHighAvailability.constants'
+
+describe('filterSchemasForHighAvailability', () => {
+ const schemas = [{ name: 'public' }, { name: MULTIGRES_SCHEMA_NAME }, { name: 'other' }]
+
+ it('removes the multigres schema on high availability projects', () => {
+ expect(filterSchemasForHighAvailability(schemas, true)).toEqual([
+ { name: 'public' },
+ { name: 'other' },
+ ])
+ })
+
+ it('keeps all schemas on non high availability projects', () => {
+ expect(filterSchemasForHighAvailability(schemas, false)).toEqual(schemas)
+ })
+})
+
+describe('resolveHighAvailability', () => {
+ it('returns the project flag when set', () => {
+ expect(resolveHighAvailability({ high_availability: true })).toBe(true)
+ expect(resolveHighAvailability({ high_availability: false })).toBe(false)
+ })
+
+ it('defaults to false when the project or flag is missing', () => {
+ expect(resolveHighAvailability(undefined)).toBe(false)
+ expect(resolveHighAvailability({ high_availability: null })).toBe(false)
+ expect(resolveHighAvailability({})).toBe(false)
+ })
+})
diff --git a/apps/studio/hooks/misc/useHighAvailability.ts b/apps/studio/hooks/misc/useHighAvailability.ts
index 19beae75764..90648f6b802 100644
--- a/apps/studio/hooks/misc/useHighAvailability.ts
+++ b/apps/studio/hooks/misc/useHighAvailability.ts
@@ -1,3 +1,5 @@
+import { useMemo } from 'react'
+
import { MULTIGRES_SCHEMA_NAME, resolveHighAvailability } from './useHighAvailability.constants'
import { useSelectedProjectQuery } from './useSelectedProject'
@@ -23,3 +25,18 @@ export function filterSchemasForHighAvailability<T extends { name: string }>(
return schemas.filter((schema) => schema.name !== MULTIGRES_SCHEMA_NAME)
}
+
+/**
+ * Memoized `filterSchemasForHighAvailability` bound to the selected project's
+ * high availability state.
+ */
+export function useSchemasFilteredForHighAvailability<T extends { name: string }>(
+ schemas: T[] | undefined
+): T[] {
+ const { isHighAvailability } = useHighAvailability()
+
+ return useMemo(
+ () => filterSchemasForHighAvailability(schemas ?? [], isHighAvailability),
+ [schemas, isHighAvailability]
+ )
+}