The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: new project statuses (#27213)
Alaister Youngc918aea9eefa
diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.utils.ts b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.utils.tsindex 26b01d598e2..960d73a495e 100644--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.utils.ts+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.utils.ts@@ -14,9 +14,18 @@ export const inferProjectStatus = (project: ProjectInfo) => {case PROJECT_STATUS.INACTIVE:status = 'isPaused'break+ case PROJECT_STATUS.PAUSE_FAILED:+ status = 'isPauseFailed'+ break+ case PROJECT_STATUS.RESTARTING:+ status = 'isRestarting'+ breakcase PROJECT_STATUS.RESTORING:status = 'isRestoring'break+ case PROJECT_STATUS.RESTORE_FAILED:+ status = 'isRestoreFailed'+ breakcase PROJECT_STATUS.UNKNOWN:case PROJECT_STATUS.COMING_UP:status = 'isComingUp'@@ -29,6 +38,9 @@ export type InferredProjectStatus =| 'isHealthy'| 'isPausing'| 'isPaused'+ | 'isPauseFailed'+ | 'isRestarting'| 'isRestoring'+ | 'isRestoreFailed'| 'isComingUp'| undefineddiff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsxindex 65fa35bf8ba..7a4dca27677 100644--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx@@ -39,8 +39,11 @@ export const ProjectCardStatus = ({const getTitle = () => {if (projectStatus === 'isPaused') return 'Project is paused'if (projectStatus === 'isPausing') return 'Project is pausing'+ if (projectStatus === 'isRestarting') return 'Project is restarting'if (projectStatus === 'isComingUp') return 'Project is coming up'if (projectStatus === 'isRestoring') return 'Project is restoring'+ if (projectStatus === 'isRestoreFailed') return 'Project restore failed'+ if (projectStatus === 'isPauseFailed') return 'Project pause failed'if (!resourceWarnings) return undefined@@ -55,8 +58,11 @@ export const ProjectCardStatus = ({const getDescription = () => {if (projectStatus === 'isPaused') return 'This project will not accept requests until resumed'if (projectStatus === 'isPausing') return 'The pause process will complete in a few minutes'+ if (projectStatus === 'isRestarting') return 'Your project will be ready in a few minutes'if (projectStatus === 'isComingUp') return 'Your project will be ready in a few minutes'if (projectStatus === 'isRestoring') return 'Your project will be ready in a few minutes'+ if (projectStatus === 'isRestoreFailed') return 'Please contact support for assistance'+ if (projectStatus === 'isPauseFailed') return 'Please contact support for assistance'if (!resourceWarnings) return undefined@@ -95,7 +101,9 @@ export const ProjectCardStatus = ({>{projectStatus === 'isPaused' || projectStatus === 'isPausing' ? (<IconPauseCircle strokeWidth={1.5} size={12} />- ) : projectStatus === 'isRestoring' || projectStatus === 'isComingUp' ? (+ ) : projectStatus === 'isRestoring' ||+ projectStatus === 'isComingUp' ||+ projectStatus === 'isRestarting' ? (<RefreshCcw strokeWidth={1.5} size={12} />) : (<AlertTriangle strokeWidth={1.5} size={12} />diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsxindex 75b9ad11351..2f9a4b10c99 100644--- a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx+++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx@@ -11,7 +11,7 @@ import {} from 'components/layouts/ProjectLayout/ProjectContext'import { useProjectRestartMutation } from 'data/projects/project-restart-mutation'import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation'-import { setProjectPostgrestStatus } from 'data/projects/projects-query'+import { setProjectStatus } from 'data/projects/projects-query'import { useCheckPermissions, useFlag } from 'hooks'import {Button,@@ -76,7 +76,7 @@ const RestartServerButton = () => {}const onRestartSuccess = () => {- setProjectPostgrestStatus(queryClient, projectRef, 'OFFLINE')+ setProjectStatus(queryClient, projectRef, 'RESTARTING')toast.success('Restarting server...')router.push(`/project/${projectRef}`)setServiceToRestart(undefined)diff --git a/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx b/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsxnew file mode 100644index 00000000000..2fd1b163ea3--- /dev/null+++ b/apps/studio/components/layouts/ProjectLayout/PauseFailedState.tsx@@ -0,0 +1,42 @@+import Link from 'next/link'+import { Button } from 'ui'+import { CriticalIcon } from 'ui-patterns/Icons/StatusIcons'++import { useProjectContext } from './ProjectContext'++const PauseFailedState = () => {+ const { project } = useProjectContext()++ return (+ <div className="flex items-center justify-center h-full">+ <div className="bg-surface-100 border border-overlay rounded-md w-3/4 lg:w-1/2">+ <div className="space-y-6 pt-6">+ <div className="flex px-8 space-x-8">+ <div className="mt-1">+ <CriticalIcon className="w-5 h-5" />+ </div>+ <div className="space-y-1">+ <p>Something went wrong while pausing your project</p>+ <p className="text-sm text-foreground-light">+ Your project's data is intact, but your project is inaccessible due to the failure+ while pausing. Please contact support for assistance.+ </p>+ </div>+ </div>++ <div className="border-t border-overlay flex items-center justify-end py-4 px-8">+ <Button asChild type="default">+ <Link+ href={`/support/new?category=Database_unresponsive&ref=${project?.ref}&subject=Restoration%20failed%20for%20project`}+ >+ Contact support+ </Link>+ </Button>+ </div>+ </div>+ </div>+ </div>+ )+}++export default PauseFailedStatediff --git a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsxindex 52971bb3e0c..87e115bc729 100644--- a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx+++ b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx@@ -10,6 +10,7 @@ import ResourceExhaustionWarningBanner from 'components/ui/ResourceExhaustionWarimport { useFlag, useSelectedOrganization, useSelectedProject, withAuth } from 'hooks'import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'+import { ResizableHandle, ResizablePanel, ResizablePanelGroup, cn } from 'ui'import AppLayout from '../AppLayout/AppLayout'import EnableBranchingModal from '../AppLayout/EnableBranchingButton/EnableBranchingModal'import BuildingState from './BuildingState'@@ -17,13 +18,15 @@ import ConnectingState from './ConnectingState'import { LayoutHeader } from './LayoutHeader'import LoadingState from './LoadingState'import NavigationBar from './NavigationBar/NavigationBar'+import PauseFailedState from './PauseFailedState'import PausingState from './PausingState'import ProductMenuBar from './ProductMenuBar'import { ProjectContextProvider } from './ProjectContext'import ProjectPausedState from './ProjectPausedState'+import RestartingState from './RestartingState'+import RestoreFailedState from './RestoreFailedState'import RestoringState from './RestoringState'import { UpgradingState } from './UpgradingState'-import { ResizableHandle, ResizablePanelGroup, ResizablePanel, cn } from 'ui'// [Joshen] This is temporary while we unblock users from managing their project// if their project is not responding well for any reason. Eventually needs a bit of an overhaul@@ -221,14 +224,17 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrappconst requiresPostgrestConnection = !routesToIgnorePostgrestConnection.includes(router.pathname)const requiresProjectDetails = !routesToIgnoreProjectDetailsRequest.includes(router.pathname)+ const isRestarting = selectedProject?.status === PROJECT_STATUS.RESTARTINGconst isProjectUpgrading = selectedProject?.status === PROJECT_STATUS.UPGRADINGconst isProjectRestoring = selectedProject?.status === PROJECT_STATUS.RESTORING+ const isProjectRestoreFailed = selectedProject?.status === PROJECT_STATUS.RESTORE_FAILEDconst isProjectBuilding =selectedProject?.status === PROJECT_STATUS.COMING_UP ||selectedProject?.status === PROJECT_STATUS.UNKNOWNconst isProjectPausing =selectedProject?.status === PROJECT_STATUS.GOING_DOWN ||selectedProject?.status === PROJECT_STATUS.PAUSING+ const isProjectPauseFailed = selectedProject?.status === PROJECT_STATUS.PAUSE_FAILEDconst isProjectOffline = selectedProject?.postgrestStatus === 'OFFLINE'useEffect(() => {@@ -239,6 +245,10 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrappreturn router.pathname.endsWith('[ref]') ? <LoadingState /> : <Loading />}+ if (isRestarting) {+ return <RestartingState />+ }+if (isProjectUpgrading) {return <UpgradingState />}@@ -247,6 +257,10 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrappreturn <PausingState project={selectedProject} />}+ if (isProjectPauseFailed) {+ return <PauseFailedState />+ }+if (requiresPostgrestConnection && isProjectOffline) {return <ConnectingState project={selectedProject} />}@@ -255,6 +269,10 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrappreturn <RestoringState />}+ if (isProjectRestoreFailed) {+ return <RestoreFailedState />+ }+if (requiresDbConnection && isProjectBuilding) {return <BuildingState />}diff --git a/apps/studio/components/layouts/ProjectLayout/RestartingState.tsx b/apps/studio/components/layouts/ProjectLayout/RestartingState.tsxnew file mode 100644index 00000000000..6394fd5627d--- /dev/null+++ b/apps/studio/components/layouts/ProjectLayout/RestartingState.tsx@@ -0,0 +1,42 @@+import { useParams } from 'common'+import { Loader2 } from 'lucide-react'++import { useProjectDetailQuery } from 'data/projects/project-detail-query'+import { PROJECT_STATUS } from 'lib/constants'++const RestartingState = () => {+ const { ref } = useParams()+ useProjectDetailQuery(+ { ref },+ {+ // setting a refetch interval here will cause the `useSelectedProject()` in `ProjectLayout.tsx` to+ // rerender every 4 seconds while the project is restarting. Once restarting is complete, it will+ // no longer show this state.+ refetchInterval(data) {+ return data?.status !== PROJECT_STATUS.ACTIVE_HEALTHY ? 4000 : false+ },+ }+ )++ return (+ <div className="flex items-center justify-center h-full">+ <div className="bg-surface-100 border border-overlay rounded-md w-3/4 lg:w-1/2">+ <div className="space-y-6 py-6">+ <div className="flex px-8 space-x-8">+ <div className="mt-1">+ <Loader2 className="animate-spin" size={18} />+ </div>+ <div className="space-y-1">+ <p>Restarting...</p>+ <p className="text-sm text-foreground-light">+ Restarting can take a few minutes. Your project will be offline while it restarts.+ </p>+ </div>+ </div>+ </div>+ </div>+ </div>+ )+}++export default RestartingStatediff --git a/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsxnew file mode 100644index 00000000000..5e6273c6149--- /dev/null+++ b/apps/studio/components/layouts/ProjectLayout/RestoreFailedState.tsx@@ -0,0 +1,42 @@+import Link from 'next/link'+import { Button } from 'ui'+import { CriticalIcon } from 'ui-patterns/Icons/StatusIcons'++import { useProjectContext } from './ProjectContext'++const RestoreFailedState = () => {+ const { project } = useProjectContext()++ return (+ <div className="flex items-center justify-center h-full">+ <div className="bg-surface-100 border border-overlay rounded-md w-3/4 lg:w-1/2">+ <div className="space-y-6 pt-6">+ <div className="flex px-8 space-x-8">+ <div className="mt-1">+ <CriticalIcon className="w-5 h-5" />+ </div>+ <div className="space-y-1">+ <p>Something went wrong while restoring your project</p>+ <p className="text-sm text-foreground-light">+ Your project's data is intact, but your project is inaccessible due to the+ restoration failure. Please contact support for assistance.+ </p>+ </div>+ </div>++ <div className="border-t border-overlay flex items-center justify-end py-4 px-8">+ <Button asChild type="default">+ <Link+ href={`/support/new?category=Database_unresponsive&ref=${project?.ref}&subject=Restoration%20failed%20for%20project`}+ >+ Contact support+ </Link>+ </Button>+ </div>+ </div>+ </div>+ </div>+ )+}++export default RestoreFailedStatediff --git a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsxindex 67dc31d1560..a4f75929165 100644--- a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx+++ b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx@@ -1,9 +1,9 @@import { useQueryClient } from '@tanstack/react-query'import { useParams } from 'common'-import Link from 'next/link'import { useEffect, useRef, useState } from 'react'-import { Button, IconAlertCircle, IconCheckCircle, IconLoader } from 'ui'+import { Button, IconCheckCircle, IconLoader } from 'ui'+import { projectKeys } from 'data/projects/keys'import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query'import { getWithTimeout } from 'lib/common/fetch'import { API_URL, PROJECT_STATUS } from 'lib/constants'@@ -16,7 +16,6 @@ const RestoringState = () => {const checkServerInterval = useRef<number>()const [loading, setLoading] = useState(false)- const [isFailed, setIsFailed] = useState(false)const [isCompleted, setIsCompleted] = useState(false)useEffect(() => {@@ -32,12 +31,11 @@ const RestoringState = () => {})if (projectStatus && !projectStatus.error) {const { status } = projectStatus- if (status === PROJECT_STATUS.RESTORATION_FAILED) {- clearInterval(checkServerInterval.current)- setIsFailed(true)- } else if (status === PROJECT_STATUS.ACTIVE_HEALTHY) {+ if (status === PROJECT_STATUS.ACTIVE_HEALTHY) {clearInterval(checkServerInterval.current)setIsCompleted(true)+ } else {+ queryClient.invalidateQueries(projectKeys.detail(ref))}}}@@ -71,32 +69,6 @@ const RestoringState = () => {</Button></div></div>- ) : isFailed ? (- <div className="space-y-6 pt-6">- <div className="flex px-8 space-x-8">- <div className="mt-1">- <IconAlertCircle size={18} strokeWidth={2} />- </div>- <div className="space-y-1">- <p>Something went wrong while restoring your project</p>- <p className="text-sm text-foreground-light">- Our engineers have already been notified of this, do hang tight while we are- investigating into the issue.- </p>- </div>- </div>- {isFailed && (- <div className="border-t border-overlay flex items-center justify-end py-4 px-8">- <Button asChild type="default">- <Link- href={`/support/new?category=Database_unresponsive&ref=${project?.ref}&subject=Restoration%20failed%20for%20project`}- >- Contact support- </Link>- </Button>- </div>- )}- </div>) : (<div className="space-y-6 py-6"><div className="flex px-8 space-x-8">diff --git a/apps/studio/data/projects/project-detail-query.ts b/apps/studio/data/projects/project-detail-query.tsindex 66427808b74..6f791b0c85b 100644--- a/apps/studio/data/projects/project-detail-query.ts+++ b/apps/studio/data/projects/project-detail-query.ts@@ -10,13 +10,14 @@ export type ProjectDetailVariables = { ref?: string }export type ProjectMinimal = components['schemas']['ProjectInfo']export type ProjectDetail = components['schemas']['ProjectDetailResponse']-export interface Project extends ProjectDetail {+export interface Project extends Omit<ProjectDetail, 'status'> {/*** postgrestStatus is available on client side only.* We use this status to check if a project instance is HEALTHY or not* If not we will show ConnectingState and run a polling until it's back online*/postgrestStatus?: 'ONLINE' | 'OFFLINE'+ status: components['schemas']['ResourceWithServicesStatusResponse']['status']}export async function getProjectDetail({ ref }: ProjectDetailVariables, signal?: AbortSignal) {diff --git a/apps/studio/data/projects/projects-query.ts b/apps/studio/data/projects/projects-query.tsindex cbb2067adb6..89d28eb0da6 100644--- a/apps/studio/data/projects/projects-query.ts+++ b/apps/studio/data/projects/projects-query.ts@@ -11,13 +11,15 @@ export type ProjectsVariables = {ref?: string}-export type ProjectInfo = components['schemas']['ProjectInfo']+export type ProjectInfo = components['schemas']['ProjectInfo'] & {+ status: components['schemas']['ResourceWithServicesStatusResponse']['status']+}export async function getProjects(signal?: AbortSignal) {const { data, error } = await get('/platform/projects', { signal })if (error) handleError(error)- return data+ return data as ProjectInfo[]}export type ProjectsData = Awaited<ReturnType<typeof getProjects>>diff --git a/apps/studio/lib/constants/infrastructure.ts b/apps/studio/lib/constants/infrastructure.tsindex a8f3212bd34..c7a15c75386 100644--- a/apps/studio/lib/constants/infrastructure.ts+++ b/apps/studio/lib/constants/infrastructure.ts@@ -69,7 +69,7 @@ export const PROVIDERS = {} as constexport const PROJECT_STATUS: {- [key: string]: components['schemas']['ProjectDetailResponse']['status']+ [key: string]: components['schemas']['ResourceWithServicesStatusResponse']['status']} = {INACTIVE: 'INACTIVE',ACTIVE_HEALTHY: 'ACTIVE_HEALTHY',@@ -79,12 +79,12 @@ export const PROJECT_STATUS: {GOING_DOWN: 'GOING_DOWN',INIT_FAILED: 'INIT_FAILED',REMOVED: 'REMOVED',+ RESTARTING: 'RESTARTING',RESTORING: 'RESTORING',+ RESTORE_FAILED: 'RESTORE_FAILED',UPGRADING: 'UPGRADING',- // @ts-ignore [Joshen] API codegen seems to be wrong here, pausing is still a valid statusPAUSING: 'PAUSING',- // @ts-ignore [Joshen] This is no longer part of the project status enum, but leaving here for now just in case- RESTORATION_FAILED: 'RESTORATION_FAILED',+ PAUSE_FAILED: 'PAUSE_FAILED',}export const DEFAULT_MINIMUM_PASSWORD_STRENGTH = 4diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsxindex 7a9a56becf7..b0ed5dafb40 100644--- a/apps/studio/pages/new/[slug].tsx+++ b/apps/studio/pages/new/[slug].tsx@@ -1,5 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { PermissionAction } from '@supabase/shared-types/out/constants'+import { PopoverSeparator } from '@ui/components/shadcn/ui/popover'import { components } from 'api-types'import { useParams } from 'common'import {@@ -19,6 +20,7 @@ import {ProjectCreateVariables,useProjectCreateMutation,} from 'data/projects/project-create-mutation'+import { useProjectsQuery } from 'data/projects/projects-query'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import generator from 'generate-password-browser'import { useCheckPermissions, useFlag, withAuth } from 'hooks'@@ -26,6 +28,7 @@ import {CloudProvider,DEFAULT_MINIMUM_PASSWORD_STRENGTH,DEFAULT_PROVIDER,+ PROJECT_STATUS,PROVIDERS,} from 'lib/constants'import { passwordStrength } from 'lib/helpers'@@ -59,10 +62,8 @@ import {} from 'ui'import { Input } from 'ui-patterns/DataInputs/Input'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'-import { z } from 'zod'import { InfoTooltip } from 'ui-patterns/info-tooltip'-import { useProjectsQuery } from 'data/projects/projects-query'-import { PopoverSeparator } from '@ui/components/shadcn/ui/popover'+import { z } from 'zod'type DesiredInstanceSize = components['schemas']['DesiredInstanceSize']@@ -173,7 +174,8 @@ const Wizard: NextPageWithLayout = () => {const { data: allProjects } = useProjectsQuery({})const organizationProjects =allProjects?.filter(- (project) => project.organization_id === currentOrg?.id && project.status !== 'paused'+ (project) =>+ project.organization_id === currentOrg?.id && project.status !== PROJECT_STATUS.INACTIVE) ?? []const { data: orgSubscription } = useOrgSubscriptionQuery({