Skip to content

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

fix: allow users to remove missing schemas from the data API (#46169)

Gildas Garcia0283d92505fb
diff --git a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
index 596d9541816..db77567e9ce 100644
--- a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
+++ b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx
@@ -57,6 +57,11 @@ export const ExposedSchemaSelector = ({
[allSchemas]
)
+ const missingExposedSchema = useMemo(
+ () => selectedSchemas.filter((schema) => !schemas.some((s) => s.name === schema)),
+ [schemas, selectedSchemas]
+ )
+
const selectedSet = useMemo(() => new Set(selectedSchemas), [selectedSchemas])
const selectedCount = schemas.filter((s) => selectedSet.has(s.name)).length
@@ -110,6 +115,26 @@ export const ExposedSchemaSelector = ({
</p>
</CommandEmpty>
<ScrollArea className={schemas.length > 7 ? 'h-[210px]' : ''}>
+ {missingExposedSchema.map((schema) => (
+ <CommandItem
+ key={schema}
+ value={schema}
+ className="cursor-pointer w-full"
+ onSelect={() => {
+ onToggleSchema(schema)
+ }}
+ >
+ <div className="w-full flex flex-col">
+ <div className="w-full flex items-center gap-x-2">
+ <Check size={16} className="text-brand shrink-0" />
+ <span className="truncate">{schema}</span>
+ </div>
+ <span className="pl-6 text-destructive text-[11px]">
+ This schema does not exist
+ </span>
+ </div>
+ </CommandItem>
+ ))}
{schemas.map((schema) => {
const isExposed = selectedSet.has(schema.name)
diff --git a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
index c1d3fcdaf0e..c62cad5a5a2 100644
--- a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
+++ b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
@@ -260,6 +260,11 @@ export const PostgrestConfig = () => {
name: 'functionNamesToRemove',
})
+ const missingExposedSchema = useMemo(
+ () => watchedDbSchema.filter((schema) => !allSchemas.some((s) => s.name === schema)),
+ [allSchemas, watchedDbSchema]
+ )
+
return (
<PageSection id="postgrest-config" className="first:pt-0">
<PageSectionContent>
@@ -282,6 +287,9 @@ export const PostgrestConfig = () => {
layout="flex-row-reverse"
label="Exposed schemas"
description="Select schemas to include in the Data API. Schemas must be included before tables can be exposed."
+ error={
+ missingExposedSchema.length > 0 ? 'Some exposed schemas are missing' : null
+ }
>
<ExposedSchemaSelector
selectedSchemas={watchedDbSchema}