The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactor: use database status from general health check endpoint (#34629)
Kevin Grüneberg8d48d5bfae13
diff --git a/apps/studio/components/interfaces/Home/ServiceStatus.tsx b/apps/studio/components/interfaces/Home/ServiceStatus.tsxindex 7f610fabb2d..2d0699bfedc 100644--- a/apps/studio/components/interfaces/Home/ServiceStatus.tsx+++ b/apps/studio/components/interfaces/Home/ServiceStatus.tsx@@ -5,7 +5,6 @@ import { useEffect, useState } from 'react'import { useParams } from 'common'import { useEdgeFunctionServiceStatusQuery } from 'data/service-status/edge-functions-status-query'-import { usePostgresServiceStatusQuery } from 'data/service-status/postgres-service-status-query'import {ProjectServiceStatus,useProjectServiceStatusQuery,@@ -112,24 +111,12 @@ const ServiceStatus = () => {refetchInterval: (data) => (!data?.healthy ? 5000 : false),})- const {- isLoading: isLoadingPostgres,- isSuccess: isSuccessPostgres,- refetch: refetchPostgresServiceStatus,- } = usePostgresServiceStatusQuery(- {- projectRef: ref,- connectionString: project?.connectionString,- },- {- refetchInterval: (data) => (data === null ? 5000 : false),- }- )const authStatus = status?.find((service) => service.name === 'auth')const restStatus = status?.find((service) => service.name === 'rest')const realtimeStatus = status?.find((service) => service.name === 'realtime')const storageStatus = status?.find((service) => service.name === 'storage')+ const dbStatus = status?.find((service) => service.name === 'db')// [Joshen] Need individual troubleshooting docs for each service eventually for users to self serveconst services: {@@ -145,8 +132,9 @@ const ServiceStatus = () => {name: 'Database',error: undefined,docsUrl: undefined,- isLoading: isLoadingPostgres,- isSuccess: isSuccessPostgres,+ isLoading: isLoading,+ isSuccess: dbStatus?.healthy,+ status: dbStatus?.status,logsUrl: '/logs/postgres-logs',},{@@ -230,7 +218,6 @@ const ServiceStatus = () => {timer = setTimeout(() => {refetchServiceStatus()- refetchPostgresServiceStatus()refetchEdgeFunctionServiceStatus()}, remainingTimeTillNextCheck * 1000)}diff --git a/apps/studio/data/service-status/postgres-service-status-query.ts b/apps/studio/data/service-status/postgres-service-status-query.tsdeleted file mode 100644index b2343660a69..00000000000--- a/apps/studio/data/service-status/postgres-service-status-query.ts+++ /dev/null@@ -1,57 +0,0 @@-import { useQuery, UseQueryOptions } from '@tanstack/react-query'--import { handleError, post } from 'data/fetchers'-import type { ResponseError } from 'types'-import { serviceStatusKeys } from './keys'--export type PostgresServiceStatusVariables = {- projectRef?: string- connectionString?: string-}--export async function getPostgresServiceStatus(- { projectRef, connectionString }: PostgresServiceStatusVariables,- signal?: AbortSignal-) {- if (!projectRef) throw new Error('projectRef is required')- if (!connectionString) throw new Error('connectionString is required')-- let headers = new Headers()- headers.set('x-connection-encrypted', connectionString)-- const { error } = await post('/platform/pg-meta/{ref}/query', {- params: {- header: { 'x-connection-encrypted': connectionString! },- path: { ref: projectRef },- // @ts-expect-error Intentional key for easier reference of query in the network tab- query: { key: 'service_status' },- },- body: { query: 'select 1' },- headers,- signal,- })-- if (error) handleError(error)- return error === undefined-}--export type PostgresServiceStatusData = Awaited<ReturnType<typeof getPostgresServiceStatus>>-export type PostgresServiceStatusError = ResponseError--export const usePostgresServiceStatusQuery = <TData = PostgresServiceStatusData>(- { projectRef, connectionString }: PostgresServiceStatusVariables,- {- enabled = true,- ...options- }: UseQueryOptions<PostgresServiceStatusData, PostgresServiceStatusError, TData> = {}-) =>- useQuery<PostgresServiceStatusData, PostgresServiceStatusError, TData>(- serviceStatusKeys.postgres(projectRef),- ({ signal }) => getPostgresServiceStatus({ projectRef, connectionString }, signal),- {- enabled:- enabled && typeof projectRef !== 'undefined' && typeof connectionString !== 'undefined',- staleTime: 0,- ...options,- }- )diff --git a/apps/studio/data/service-status/service-status-query.ts b/apps/studio/data/service-status/service-status-query.tsindex 4b47577a932..78eb015b8ff 100644--- a/apps/studio/data/service-status/service-status-query.ts+++ b/apps/studio/data/service-status/service-status-query.ts@@ -18,7 +18,7 @@ export async function getProjectServiceStatus(params: {path: { ref: projectRef },query: {- services: ['auth', 'realtime', 'rest', 'storage'],+ services: ['auth', 'realtime', 'rest', 'storage', 'db'],},},signal,