The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore(studio): link directly to Postgres upgrade blockers (#41527)
Danny Whiteabc37edaa78a
diff --git a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx b/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsxindex 7fb1252a2a7..e3353565e90 100644--- a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx+++ b/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx@@ -4,6 +4,11 @@ import { cn } from 'ui'import { Admonition } from 'ui-patterns'+/**+ * @deprecated Use Admonition from ui-patterns instead+ * Pass actions as a prop to the Admonition component+ */+interface NoticeBarProps extends Omit<ComponentProps<typeof Admonition>, 'description'> {title?: stringdescription?: stringdiff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsxindex 65f18ec09ad..4522f2ce4c3 100644--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx@@ -1,3 +1,5 @@+import Link from 'next/link'+import { useFlag, useParams } from 'common'import { NoticeBar } from 'components/interfaces/DiskManagement/ui/NoticeBar'import {@@ -13,29 +15,14 @@ import { useProjectServiceVersionsQuery } from 'data/projects/project-service-veimport { useReadReplicasQuery } from 'data/read-replicas/replicas-query'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'-import Link from 'next/link'-import {- AlertDescription_Shadcn_,- AlertTitle_Shadcn_,- Alert_Shadcn_,- Badge,- Button,- Input,- Tooltip,- TooltipContent,- TooltipTrigger,-} from 'ui'+import { Badge, Button, Input, Tooltip, TooltipContent, TooltipTrigger } from 'ui'+import { Admonition } from 'ui-patterns/admonition'import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'import { ProjectUpgradeAlert } from '../General/Infrastructure/ProjectUpgradeAlert'import { InstanceConfiguration } from './InfrastructureConfiguration/InstanceConfiguration'-import {- ObjectsToBeDroppedWarning,- ReadReplicasWarning,- UnsupportedExtensionsWarning,- UserDefinedObjectsInInternalSchemasWarning,-} from './UpgradeWarnings'+import { ReadReplicasWarning, ValidationErrorsWarning } from './UpgradeWarnings'-const InfrastructureInfo = () => {+export const InfrastructureInfo = () => {const { ref } = useParams()const { data: project } = useSelectedProjectQuery()@@ -81,9 +68,7 @@ const InfrastructureInfo = () => {const isInactive = project?.status === 'INACTIVE'const hasReadReplicas = (databases ?? []).length > 1- const hasObjectsToBeDropped = (data?.objects_to_be_dropped ?? []).length > 0- const hasUnsupportedExtensions = (data?.unsupported_extensions || []).length > 0- const hasObjectsInternalSchema = (data?.user_defined_objects_in_internal_schemas || []).length > 0+ const hasValidationErrors = (data?.validation_errors ?? []).length > 0return (<>@@ -117,21 +102,19 @@ const InfrastructureInfo = () => {<ScaffoldContainer><ScaffoldSection><ScaffoldSectionDetail>- <h4 className="text-base capitalize m-0">Service Versions</h4>+ <h4 className="text-base capitalize m-0">Service versions</h4><p className="text-foreground-light text-sm pr-8 mt-1">Service versions and upgrade eligibility for your provisioned instance.</p></ScaffoldSectionDetail><ScaffoldSectionContent>{isInactive ? (- <Alert_Shadcn_>- <AlertTitle_Shadcn_>- Service versions cannot be retrieved while project is paused- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- Restoring the project will update Postgres to the newest version- </AlertDescription_Shadcn_>- </Alert_Shadcn_>+ <Admonition+ type="note"+ showIcon={false}+ title="Service versions cannot be retrieved while project is paused"+ description="Restoring the project will update Postgres to the newest version"+ />) : (<>{/* [Joshen] Double check why we need this waterfall loading behaviour here */}@@ -213,7 +196,7 @@ const InfrastructureInfo = () => {</>)}- {showDatabaseUpgrades && data.eligible ? (+ {showDatabaseUpgrades && data && data.eligible ? (hasReadReplicas ? (<ReadReplicasWarning latestPgVersion={latestPgVersion} />) : (@@ -221,20 +204,8 @@ const InfrastructureInfo = () => {)) : null}- {showDatabaseUpgrades && !data.eligible ? (- hasObjectsToBeDropped ? (- <ObjectsToBeDroppedWarning- objectsToBeDropped={data.objects_to_be_dropped}- />- ) : hasUnsupportedExtensions ? (- <UnsupportedExtensionsWarning- unsupportedExtensions={data.unsupported_extensions}- />- ) : hasObjectsInternalSchema ? (- <UserDefinedObjectsInInternalSchemasWarning- objects={data.user_defined_objects_in_internal_schemas}- />- ) : null+ {showDatabaseUpgrades && data && !data.eligible && hasValidationErrors ? (+ <ValidationErrorsWarning validationErrors={data.validation_errors ?? []} />) : null}</>)}@@ -246,5 +217,3 @@ const InfrastructureInfo = () => {</>)}--export default InfrastructureInfodiff --git a/apps/studio/components/interfaces/Settings/Infrastructure/UpgradeWarnings.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/UpgradeWarnings.tsxindex 176505db0ce..660a5fc060c 100644--- a/apps/studio/components/interfaces/Settings/Infrastructure/UpgradeWarnings.tsx+++ b/apps/studio/components/interfaces/Settings/Infrastructure/UpgradeWarnings.tsx@@ -1,146 +1,147 @@import Link from 'next/link'-import { useParams } from 'common'+import { ProjectUpgradeEligibilityValidationError } from '@/data/config/project-upgrade-eligibility-query'+import { useFlag, useParams } from 'common'import { InlineLink } from 'components/ui/InlineLink'import { DOCS_URL } from 'lib/constants'-import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, Badge, Button } from 'ui'+import { Button } from 'ui'+import { Admonition } from 'ui-patterns/admonition'export const ReadReplicasWarning = ({ latestPgVersion }: { latestPgVersion: string }) => {+ const { ref } = useParams()+ const unifiedReplication = useFlag('unifiedReplication')+return (- <Alert_Shadcn_>- <AlertTitle_Shadcn_>- A new version of Postgres is available for your project- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- You will need to remove all read replicas prior to upgrading your Postgres version to the- latest available ({latestPgVersion}).- </AlertDescription_Shadcn_>- </Alert_Shadcn_>+ <Admonition+ type="note"+ showIcon={false}+ title="A newer version of Postgres is available"+ description={`You will need to remove all read replicas prior to upgrading your Postgres version to the latest available (${latestPgVersion}).`}+ actions={+ unifiedReplication ? (+ <Button asChild type="default">+ <Link href={`/project/${ref}/database/replication`}>Manage read replicas</Link>+ </Button>+ ) : undefined+ }+ />)}-export const ObjectsToBeDroppedWarning = ({- objectsToBeDropped,-}: {- objectsToBeDropped: string[]-}) => {- const { ref } = useParams()- return (- <Alert_Shadcn_ title="A newer version of Postgres is available for your project">- <AlertTitle_Shadcn_>A newer version of Postgres is available</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_ className="flex flex-col gap-3">- <>- <p className="mb-1">- The following objects are not supported and must be removed before upgrading.{' '}- <InlineLink- className="text-foreground-lighter hover:text-foreground transition-colors"- href={`${DOCS_URL}/guides/platform/upgrading#extensions`}- target="_blank"- rel="noopener noreferrer"- >- Learn more- </InlineLink>- </p>-- {/* Old */}- <ul className="pl-4 pb-3">- {objectsToBeDropped.map((obj) => (- <li className="list-disc" key={obj}>- {obj}- </li>- ))}- </ul>+const getValidationErrorTitle = (error: ProjectUpgradeEligibilityValidationError): string => {+ switch (error.type) {+ case 'objects_depending_on_pg_cron':+ return error.dependents.join(', ')+ case 'indexes_referencing_ll_to_earth':+ return `${error.schema_name}.${error.index_name}`+ case 'function_using_obsolete_lang':+ return `${error.schema_name}.${error.function_name}`+ case 'unsupported_extension':+ return error.extension_name+ case 'unsupported_fdw_handler':+ return error.fdw_name+ case 'unlogged_table_with_persistent_sequence':+ return `${error.schema_name}.${error.table_name}`+ case 'user_defined_objects_in_internal_schemas':+ return `${error.schema_name}.${error.obj_name}`+ case 'active_replication_slot':+ return error.slot_name+ }+}- <Button className="w-fit" size="tiny" type="default" asChild>- <Link href={`/project/${ref}/database/functions`}>Manage functions</Link>- </Button>- </>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- )+const getValidationErrorDescription = (error: ProjectUpgradeEligibilityValidationError): string => {+ switch (error.type) {+ case 'objects_depending_on_pg_cron':+ return 'Remove objects that depend on pg_cron'+ case 'indexes_referencing_ll_to_earth':+ return `Drop or recreate the index on table ${error.schema_name}.${error.table_name} that references ll_to_earth()`+ case 'function_using_obsolete_lang':+ return `Update the function to use a supported language instead of ${error.lang_name}`+ case 'unsupported_extension':+ return 'Remove the unsupported extension'+ case 'unsupported_fdw_handler':+ return `Update or remove the FDW using the obsolete handler ${error.fdw_handler_name}`+ case 'unlogged_table_with_persistent_sequence':+ return `Convert the sequence ${error.sequence_name} to unlogged or convert the table to logged`+ case 'user_defined_objects_in_internal_schemas':+ return `Move the ${error.obj_type} to your own schema`+ case 'active_replication_slot':+ return 'Drop the active replication slot'+ }}-export const UnsupportedExtensionsWarning = ({- unsupportedExtensions,-}: {- unsupportedExtensions: string[]-}) => {- const { ref } = useParams()+const ValidationErrorItem = ({ error }: { error: ProjectUpgradeEligibilityValidationError }) => {+ const { ref: projectRef } = useParams()+ const title = getValidationErrorTitle(error)+ const description = getValidationErrorDescription(error)- return (- <Alert_Shadcn_ title="A newer version of Postgres is available">- <AlertTitle_Shadcn_>A newer version of Postgres is available</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_ className="flex flex-col gap-3">- <>- <p className="mb-1">- The following extensions are not supported in newer versions of Postgres and must be- removed before upgrading.{' '}- <InlineLink- className="text-foreground-lighter hover:text-foreground transition-colors"- href={`${DOCS_URL}/guides/platform/upgrading#upgrading-to-postgres-17`}- target="_blank"- rel="noopener noreferrer"- >- Learn more- </InlineLink>- </p>+ const getManageLink = (): string | null => {+ const encode = encodeURIComponent+ switch (error.type) {+ case 'function_using_obsolete_lang':+ return `/project/${projectRef}/database/functions?schema=${encode(error.schema_name)}&search=${encode(error.function_name)}`+ case 'unsupported_extension':+ return `/project/${projectRef}/database/extensions?filter=${encode(error.extension_name)}`+ case 'indexes_referencing_ll_to_earth':+ return `/project/${projectRef}/database/indexes?schema=${encode(error.schema_name)}&search=${encode(error.index_name)}`+ case 'unlogged_table_with_persistent_sequence':+ return `/project/${projectRef}/database/tables?schema=${encode(error.schema_name)}&search=${encode(error.table_name)}`+ case 'user_defined_objects_in_internal_schemas':+ if (error.obj_type === 'function') {+ return `/project/${projectRef}/database/functions?schema=${encode(error.schema_name)}&search=${encode(error.obj_name)}`+ }+ if (error.obj_type === 'table') {+ return `/project/${projectRef}/database/tables?schema=${encode(error.schema_name)}&search=${encode(error.obj_name)}`+ }+ return null+ case 'active_replication_slot':+ return null+ case 'unsupported_fdw_handler':+ return `/project/${projectRef}/integrations`+ case 'objects_depending_on_pg_cron':+ return null+ default:+ return null+ }+ }++ const manageLink = getManageLink()- <ul className="border-t border-border-muted flex flex-col divide-y divide-border-muted">- {unsupportedExtensions.map((obj: string) => (- <li className="py-3 last:pb-0 flex flex-row justify-between gap-2" key={obj}>- <div className="flex flex-row gap-2 items-center flex-1 min-w-0">- <p className="overflow-hidden text-ellipsis whitespace-nowrap min-w-0">{obj}</p>- <Badge variant="warning" className="flex-shrink-0">- Deprecated- </Badge>- </div>- <Button size="tiny" type="default" asChild>- <Link href={`/project/${ref}/database/extensions?filter=${obj}`}>Manage</Link>- </Button>- </li>- ))}- </ul>- </>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>+ return (+ <li className="py-3 last:pb-0 flex flex-row gap-x-3 justify-between items-center">+ <div className="flex flex-col gap-y-0.5 flex-1 min-w-0">+ <h6 className="overflow-hidden text-ellipsis whitespace-nowrap min-w-0 text-sm font-normal text-foreground">+ {title}+ </h6>+ <p className="text-foreground-lighter text-xs">{description}</p>+ </div>+ {manageLink && (+ <Button size="tiny" type="default" asChild>+ <Link href={manageLink}>Manage</Link>+ </Button>+ )}+ </li>)}-export const UserDefinedObjectsInInternalSchemasWarning = ({ objects }: { objects: string[] }) => {+export const ValidationErrorsWarning = ({+ validationErrors,+}: {+ validationErrors: ProjectUpgradeEligibilityValidationError[]+}) => {return (- <Alert_Shadcn_ title="A newer version of Postgres is available for your project">- <AlertTitle_Shadcn_>A newer version of Postgres is available</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_ className="flex flex-col gap-3">- <div>- <p className="mb-1">- The following objects must be removed from the auth/realtime/storage schemas before- upgrading:- </p>-- <ul className="pl-4">- {objects.map((obj: string) => (- <li className="list-disc" key={obj}>- {obj}- </li>- ))}- </ul>- </div>+ <Admonition type="note" showIcon={false} title="A newer version of Postgres is available">+ <div className="flex flex-col gap-3"><p>- These schemas are Supabase-managed and creating custom objects in them is no longer- supported. Check the changelog to see how to move them to your own schemas.+ The following issues must be resolved before upgrading.{' '}+ <InlineLink href={`${DOCS_URL}/guides/platform/upgrading`}>Learn more</InlineLink></p>- <div>- <Button size="tiny" type="default" asChild>- <a- href="https://github.com/orgs/supabase/discussions/34270"- target="_blank"- rel="noreferrer"- >- View changelog- </a>- </Button>- </div>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>+ <ul className="border-t border-border-muted flex flex-col divide-y divide-border-muted">+ {validationErrors.map((error, idx) => (+ <ValidationErrorItem key={`${error.type}-${idx}`} error={error} />+ ))}+ </ul>+ </div>+ </Admonition>)}diff --git a/apps/studio/data/config/project-upgrade-eligibility-query.ts b/apps/studio/data/config/project-upgrade-eligibility-query.tsindex ba890c64501..e4a94e70839 100644--- a/apps/studio/data/config/project-upgrade-eligibility-query.ts+++ b/apps/studio/data/config/project-upgrade-eligibility-query.ts@@ -12,11 +12,20 @@ export type ProjectUpgradeTargetVersion = { postgres_version: string; release_chexport type ProjectUpgradeEligibilityVariables = { projectRef?: string }export type ProjectUpgradeEligibilityResponse =components['schemas']['ProjectUpgradeEligibilityResponse']+export type ProjectUpgradeEligibilityValidationError =+ ProjectUpgradeEligibilityResponse['validation_errors'][number]+/**+ * Fetches upgrade eligibility information for a project.+ *+ * @param projectRef - The project's reference identifier+ * @returns The project upgrade eligibility response, or `undefined` if no data was returned+ * @throws Error if `projectRef` is not provided+ */export async function getProjectUpgradeEligibility({ projectRef }: ProjectUpgradeEligibilityVariables,signal?: AbortSignal-) {+): Promise<ProjectUpgradeEligibilityResponse | undefined> {if (!projectRef) throw new Error('projectRef is required')const { data, error } = await get('/v1/projects/{ref}/upgrade/eligibility', {@@ -25,7 +34,7 @@ export async function getProjectUpgradeEligibility(})if (error) handleError(error)- return data+ return data as ProjectUpgradeEligibilityResponse | undefined}export type ProjectUpgradeEligibilityData = Awaited<ReturnType<typeof getProjectUpgradeEligibility>>diff --git a/apps/studio/pages/project/[ref]/settings/infrastructure.tsx b/apps/studio/pages/project/[ref]/settings/infrastructure.tsxindex 78f09752ce9..aa9693585a5 100644--- a/apps/studio/pages/project/[ref]/settings/infrastructure.tsx+++ b/apps/studio/pages/project/[ref]/settings/infrastructure.tsx@@ -1,6 +1,6 @@import { InfrastructureActivity } from 'components/interfaces/Settings/Infrastructure/InfrastructureActivity'-import InfrastructureInfo from 'components/interfaces/Settings/Infrastructure/InfrastructureInfo'-import DefaultLayout from 'components/layouts/DefaultLayout'+import { InfrastructureInfo } from 'components/interfaces/Settings/Infrastructure/InfrastructureInfo'+import { DefaultLayout } from 'components/layouts/DefaultLayout'import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'import {ScaffoldContainer,