The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add number of database connections charts in database reports (#29637)
Joshen Lim9aabe4a40f7e
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsxindex 4d25cb56095..b3b7e5932ba 100644--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx@@ -1,5 +1,3 @@-import Link from 'next/link'-import { useParams } from 'common'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import {@@ -44,15 +42,13 @@ const InfrastructureInfo = () => {projectRef: ref,})const { data: databases } = useReadReplicasQuery({ projectRef: ref })- const { current_app_version, latest_app_version, requires_manual_intervention } = data || {}+ const { current_app_version, latest_app_version } = data || {}const isOnLatestVersion = current_app_version === latest_app_versionconst currentPgVersion = (current_app_version ?? '').split('supabase-postgres-')[1]const latestPgVersion = (latest_app_version ?? '').split('supabase-postgres-')[1]const isInactive = project?.status === 'INACTIVE'const hasReadReplicas = (databases ?? []).length > 1- const subject = 'Request%20for%20Postgres%20upgrade%20for%20project'- const message = `Upgrade information:%0A• Manual intervention reason: ${requires_manual_intervention}`return (<>@@ -136,28 +132,6 @@ const InfrastructureInfo = () => {</AlertDescription_Shadcn_></Alert_Shadcn_>)}- {!data?.eligible && data?.requires_manual_intervention && (- <Alert_Shadcn_ title="A new version of Postgres is available for your project">- <AlertTitle_Shadcn_>- A new version of Postgres is available for your project- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- <p className="mb-3">- Please reach out to us via our support form if you are keen to upgrade- your Postgres version to the latest available ({latestPgVersion}).- </p>- <Button size="tiny" type="default" asChild>- <Link- href={`/support/new?category=Database_unresponsive&ref=${ref}&subject=${subject}&message=${message}`}- target="_blank"- rel="noreferrer"- >- Contact support- </Link>- </Button>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- )}{!data?.eligible && (data?.extension_dependent_objects || []).length > 0 && (<Alert_Shadcn_variant="warning"diff --git a/apps/studio/components/to-be-cleaned/Charts/ChartHandler.tsx b/apps/studio/components/to-be-cleaned/Charts/ChartHandler.tsxindex 9d0bb216d1d..c6e8ec5e6bc 100644--- a/apps/studio/components/to-be-cleaned/Charts/ChartHandler.tsx+++ b/apps/studio/components/to-be-cleaned/Charts/ChartHandler.tsx@@ -9,7 +9,10 @@ import {InfraMonitoringAttribute,useInfraMonitoringQuery,} from 'data/analytics/infra-monitoring-query'-import { useProjectDailyStatsQuery } from 'data/analytics/project-daily-stats-query'+import {+ ProjectDailyStatsAttribute,+ useProjectDailyStatsQuery,+} from 'data/analytics/project-daily-stats-query'import { Activity, BarChartIcon, Loader2 } from 'lucide-react'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'import { WarningIcon } from 'ui'@@ -70,7 +73,7 @@ const ChartHandler = ({const { data: dailyStatsData, isLoading: isFetchingDailyStats } = useProjectDailyStatsQuery({projectRef: ref as string,- attribute: attribute as InfraMonitoringAttribute,+ attribute: attribute as ProjectDailyStatsAttribute,startDate,endDate,interval: interval as AnalyticsInterval,diff --git a/apps/studio/data/analytics/infra-monitoring-query.ts b/apps/studio/data/analytics/infra-monitoring-query.tsindex 91f1b39b238..3beccd3f334 100644--- a/apps/studio/data/analytics/infra-monitoring-query.ts+++ b/apps/studio/data/analytics/infra-monitoring-query.ts@@ -12,6 +12,7 @@ export type InfraMonitoringAttribute =| 'ram_usage'| 'disk_io_consumption'| 'swap_usage'+ | 'pg_stat_database_num_backends'export type InfraMonitoringVariables = {projectRef?: stringdiff --git a/apps/studio/data/config/project-upgrade-eligibility-query.ts b/apps/studio/data/config/project-upgrade-eligibility-query.tsindex fa349e1571a..34410e665bc 100644--- a/apps/studio/data/config/project-upgrade-eligibility-query.ts+++ b/apps/studio/data/config/project-upgrade-eligibility-query.ts@@ -6,19 +6,11 @@ import { useProjectByRef } from 'hooks/misc/useSelectedProject'import { PROJECT_STATUS } from 'lib/constants/infrastructure'import type { ResponseError } from 'types'import { configKeys } from './keys'+import { components } from 'api-types'export type ProjectUpgradeEligibilityVariables = { projectRef?: string }-export type ProjectUpgradeEligibilityResponse = {- eligible: boolean- current_app_version: string- latest_app_version: string- target_upgrade_versions: { postgres_version: number; app_version: string }[]- requires_manual_intervention: string | null- potential_breaking_changes: string[]- duration_estimate_hours: number- legacy_auth_custom_roles: string[]- extension_dependent_objects: string[]-}+export type ProjectUpgradeEligibilityResponse =+ components['schemas']['ProjectUpgradeEligibilityResponse']export async function getProjectUpgradeEligibility({ projectRef }: ProjectUpgradeEligibilityVariables,@@ -28,10 +20,11 @@ export async function getProjectUpgradeEligibility(const { data, error } = await get('/v1/projects/{ref}/upgrade/eligibility', {params: { path: { ref: projectRef } },+ signal,})if (error) handleError(error)- return data as ProjectUpgradeEligibilityResponse+ return data}export type ProjectUpgradeEligibilityData = Awaited<ReturnType<typeof getProjectUpgradeEligibility>>diff --git a/apps/studio/data/projects/project-upgrade-mutation.ts b/apps/studio/data/projects/project-upgrade-mutation.tsindex e2ef8352c83..0cf93bb57a7 100644--- a/apps/studio/data/projects/project-upgrade-mutation.ts+++ b/apps/studio/data/projects/project-upgrade-mutation.ts@@ -12,7 +12,8 @@ export type ProjectUpgradeVariables = {export async function upgradeProject({ ref, target_version }: ProjectUpgradeVariables) {const { data, error } = await post('/v1/projects/{ref}/upgrade', {params: { path: { ref } },- body: { target_version },+ // @ts-expect-error release_channel param is optional on API end, but not typed properly from generated types+ body: { target_version: target_version.toString() },})if (error) handleError(error)return datadiff --git a/apps/studio/pages/project/[ref]/reports/database.tsx b/apps/studio/pages/project/[ref]/reports/database.tsxindex 9ce9b4dc911..5e565ec1dc8 100644--- a/apps/studio/pages/project/[ref]/reports/database.tsx+++ b/apps/studio/pages/project/[ref]/reports/database.tsx@@ -130,56 +130,67 @@ const DatabaseUsage = () => {<div className="space-y-6">{dateRange && (<ChartHandler+ provider="infra-monitoring"+ attribute="ram_usage"+ label="Memory usage"+ interval={dateRange.interval}startDate={dateRange?.period_start?.date}endDate={dateRange?.period_end?.date}- attribute={'ram_usage'}- label={'Memory usage'}- interval={dateRange.interval}- provider={'infra-monitoring'}/>)}{dateRange && (<ChartHandler+ provider="infra-monitoring"+ attribute="swap_usage"+ label="Swap usage"+ interval={dateRange.interval}startDate={dateRange?.period_start?.date}endDate={dateRange?.period_end?.date}- attribute={'swap_usage'}- label={'Swap usage'}- interval={dateRange.interval}- provider={'infra-monitoring'}/>)}{dateRange && (<ChartHandler+ provider="infra-monitoring"+ attribute="avg_cpu_usage"+ label="Average CPU usage"+ interval={dateRange.interval}startDate={dateRange?.period_start?.date}endDate={dateRange?.period_end?.date}- attribute={'avg_cpu_usage'}- label={'Average CPU usage'}- interval={dateRange.interval}- provider={'infra-monitoring'}/>)}{dateRange && (<ChartHandler+ provider="infra-monitoring"+ attribute="max_cpu_usage"+ label="Max CPU usage"+ interval={dateRange.interval}startDate={dateRange?.period_start?.date}endDate={dateRange?.period_end?.date}- attribute={'max_cpu_usage'}- label={'Max CPU usage'}- interval={dateRange.interval}- provider={'infra-monitoring'}/>)}{dateRange && (<ChartHandler+ provider="infra-monitoring"+ attribute="disk_io_consumption"+ label="Disk IO consumed"+ interval={dateRange.interval}startDate={dateRange?.period_start?.date}endDate={dateRange?.period_end?.date}- attribute={'disk_io_consumption'}- label={'Disk IO consumed'}+ />+ )}++ {dateRange && (+ <ChartHandler+ provider="infra-monitoring"+ attribute="pg_stat_database_num_backends"+ label="Number of database connections"interval={dateRange.interval}- provider={'infra-monitoring'}+ startDate={dateRange?.period_start?.date}+ endDate={dateRange?.period_end?.date}/>)}</div>diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 16fbc1c519f..27c4c776791 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -302,6 +302,10 @@ export interface paths {/** Gets an organization's audit logs */get: operations['OrgAuditLogsController_getAuditLogs']}+ '/platform/organizations/{slug}/available-versions': {+ /** Retrieves a list of available Postgres versions available to the organization */+ post: operations['OrganizationSlugController_getAvailableImageVersions']+ }'/platform/organizations/{slug}/billing/invoices': {/** Gets invoices for the given organization */get: operations['OrgInvoicesController_getInvoices']@@ -924,8 +928,16 @@ export interface paths {post: operations['RestartServicesController_restartServices']}'/platform/projects/{ref}/restore': {+ /** Unpauses project */+ post: operations['UnpauseController_unpauseProject']+ }+ '/platform/projects/{ref}/restore/cancel': {/** Cancels a failed restoration */- post: operations['RestoreController_cancelProjectRestoration']+ post: operations['UnpauseController_cancelProjectRestoration']+ }+ '/platform/projects/{ref}/restore/versions': {+ /** Retrieves versions to which a project can be restored */+ get: operations['UnpauseController_getAvailableImageVersions']}'/platform/projects/{ref}/run-lints': {/** Run project lints */@@ -1356,6 +1368,10 @@ export interface paths {/** Updates organization */patch: operations['OrganizationSlugController_updateOrganization']}+ '/v0/organizations/{slug}/available-versions': {+ /** Retrieves a list of available Postgres versions available to the organization */+ post: operations['OrganizationSlugController_getAvailableImageVersions']+ }'/v0/organizations/{slug}/members': {/** Gets organization's members */get: operations['MembersController_getMembers']@@ -1783,8 +1799,16 @@ export interface paths {post: operations['RestartServicesController_restartServices']}'/v0/projects/{ref}/restore': {+ /** Unpauses project */+ post: operations['UnpauseController_unpauseProject']+ }+ '/v0/projects/{ref}/restore/cancel': {/** Cancels a failed restoration */- post: operations['RestoreController_cancelProjectRestoration']+ post: operations['UnpauseController_cancelProjectRestoration']+ }+ '/v0/projects/{ref}/restore/versions': {+ /** Retrieves versions to which a project can be restored */+ get: operations['UnpauseController_getAvailableImageVersions']}'/v0/projects/{ref}/settings': {/** Gets project's settings */@@ -2246,6 +2270,7 @@ export interface components {| 'pitr_28'| 'ipv4_default'| 'auth_mfa_phone_default'+ | 'auth_mfa_web_authn_default'| 'log_drain_default'AmiSearchOptions: {search_tags?: Record<string, never>@@ -2576,8 +2601,10 @@ export interface components {db_port: numberdb_user?: stringjwt_secret?: string+ postgres_engine: stringpostgres_version: stringref: string+ release_channel: string/** @enum {string} */status:| 'ACTIVE_HEALTHY'@@ -2688,7 +2715,9 @@ export interface components {desired_instance_size?: components['schemas']['DesiredInstanceSize']git_branch?: stringpersistent?: boolean+ postgres_engine?: components['schemas']['PostgresEngine']region?: string+ release_channel?: components['schemas']['ReleaseChannel']}CreateCliLoginSessionBody: {public_key: string@@ -2846,6 +2875,8 @@ export interface components {/** @deprecated */org_id?: numberorganization_slug?: string+ postgres_engine?: components['schemas']['PostgresEngine']+ release_channel?: components['schemas']['ReleaseChannel']}CreateProjectResponse: {anon_key: string@@ -4145,6 +4176,13 @@ export interface components {name: stringproject_ids: number[] | null}+ OrganizationSlugAvailableVersionsBody: {+ provider: string+ region: string+ }+ OrganizationSlugAvailableVersionsResponse: {+ available_versions: components['schemas']['ProjectCreationVersionInfo'][]+ }OrganizationSlugResponse: {billing_email?: stringid: number@@ -4174,6 +4212,7 @@ export interface components {| 'DISK_SIZE_GB_HOURS_GP3'| 'DISK_SIZE_GB_HOURS_IO2'| 'AUTH_MFA_PHONE'+ | 'AUTH_MFA_WEB_AUTHN'| 'LOG_DRAIN_EVENTS'| 'MONTHLY_ACTIVE_THIRD_PARTY_USERS'| 'DISK_THROUGHPUT_GP3'@@ -4342,6 +4381,8 @@ export interface components {wal_keep_size?: stringwork_mem?: string}+ /** @enum {string} */+ PostgresEngine: '15'PostgresExtension: {comment: string | nulldefault_version: string@@ -4570,6 +4611,7 @@ export interface components {| 'pitr'| 'ipv4'| 'auth_mfa_phone'+ | 'auth_mfa_web_authn'| 'log_drain'/** @enum {string} */ProjectAddonVariantPricingType: 'fixed' | 'usage'@@ -4592,6 +4634,11 @@ export interface components {db_schema: stringendpoint: string}+ ProjectCreationVersionInfo: {+ postgres_engine: components['schemas']['PostgresEngine']+ release_channel: components['schemas']['ReleaseChannel']+ version: string+ }ProjectDetailResponse: {cloud_provider: stringconnectionString: string@@ -4774,8 +4821,14 @@ export interface components {ssl_enforced: booleanstatus: string}+ ProjectUnpauseVersionInfo: {+ postgres_engine: components['schemas']['PostgresEngine']+ release_channel: components['schemas']['ReleaseChannel']+ version: string+ }ProjectUpgradeEligibilityResponse: {current_app_version: string+ current_app_version_release_channel: components['schemas']['ReleaseChannel']duration_estimate_hours: numbereligible: booleanextension_dependent_objects: string[]@@ -4789,7 +4842,8 @@ export interface components {}ProjectVersion: {app_version: string- postgres_version: number+ postgres_version: components['schemas']['PostgresEngine']+ release_channel: components['schemas']['ReleaseChannel']}Provider: {created_at?: string@@ -4836,6 +4890,8 @@ export interface components {target_table_name: stringtarget_table_schema: string}+ /** @enum {string} */+ ReleaseChannel: 'internal' | 'alpha' | 'beta' | 'ga' | 'withdrawn'RemoveNetworkBanRequest: {ipv4_addresses: string[]}@@ -5023,15 +5079,6 @@ export interface components {id: numberrecovery_time_target: string}- RestoreProjectInfo: {- back_ups: components['schemas']['BackupId'][]- cloud_provider: string- id: number- organization_id: number- region: string- status: string- subscription_id: string- }RestrictionData: {grace_period_end?: stringreport_date?: string@@ -5544,6 +5591,22 @@ export interface components {TypescriptResponse: {types: string}+ UnpauseProjectAvailableVersionsResponse: {+ available_versions: components['schemas']['ProjectUnpauseVersionInfo'][]+ }+ UnpauseProjectBody: {+ postgres_engine?: components['schemas']['PostgresEngine']+ release_channel?: components['schemas']['ReleaseChannel']+ }+ UnpauseProjectInfo: {+ back_ups: components['schemas']['BackupId'][]+ cloud_provider: string+ id: number+ organization_id: number+ region: string+ status: string+ subscription_id: string+ }UpcomingInvoice: Record<string, never>UpdateAddonAdminBody: {addon_type: components['schemas']['ProjectAddonType']@@ -6213,7 +6276,8 @@ export interface components {public_env_var_prefix?: string}UpgradeDatabaseBody: {- target_version: number+ release_channel: components['schemas']['ReleaseChannel']+ target_version: string}UpsertContentBody: {content?: Record<string, never>@@ -6383,6 +6447,7 @@ export interface components {* @enum {string}*/plan?: 'free' | 'pro'+ postgres_engine?: components['schemas']['PostgresEngine']/*** @description Region you want your server to reside in* @example us-east-1@@ -6407,6 +6472,7 @@ export interface components {| 'ca-central-1'| 'ap-south-1'| 'sa-east-1'+ release_channel?: components['schemas']['ReleaseChannel']/*** @description Template URL used to create the project from the CLI.* @example https://github.com/supabase/supabase/tree/master/examples/slack-clone/nextjs-slack-clone@@ -6416,6 +6482,10 @@ export interface components {V1DatabaseResponse: {/** @description Database host */host: string+ /** @description Database engine */+ postgres_engine: string+ /** @description Release channel */+ release_channel: string/** @description Database version */version: string}@@ -6427,6 +6497,7 @@ export interface components {user_name: string}V1OrganizationSlugResponse: {+ allowed_release_channels: components['schemas']['ReleaseChannel'][]id: stringname: stringopt_in_tags: 'AI_SQL_GENERATOR_OPT_IN'[]@@ -7072,9 +7143,6 @@ export interface operations {limit: stringoffset: stringverified: string- sort?: string- order?: string- providers?: string[]}path: {/** @description Project ref */@@ -8027,6 +8095,34 @@ export interface operations {}}}+ /** Retrieves a list of available Postgres versions available to the organization */+ OrganizationSlugController_getAvailableImageVersions: {+ parameters: {+ path: {+ /** @description Organization slug */+ slug: string+ }+ }+ requestBody: {+ content: {+ 'application/json': components['schemas']['OrganizationSlugAvailableVersionsBody']+ }+ }+ responses: {+ 200: {+ content: {+ 'application/json': components['schemas']['OrganizationSlugAvailableVersionsResponse']+ }+ }+ 403: {+ content: never+ }+ /** @description Failed to determine available Postgres versions */+ 500: {+ content: never+ }+ }+ }/** Gets invoices for the given organization */OrgInvoicesController_getInvoices: {parameters: {@@ -8066,7 +8162,7 @@ export interface operations {200: {headers: {/** @description total count value */- 'X-Total-Count'?: unknown+ 'X-Total-Count'?: number}content: never}@@ -8308,6 +8404,7 @@ export interface operations {| 'DISK_SIZE_GB_HOURS_GP3'| 'DISK_SIZE_GB_HOURS_IO2'| 'AUTH_MFA_PHONE'+ | 'AUTH_MFA_WEB_AUTHN'| 'LOG_DRAIN_EVENTS'| 'MONTHLY_ACTIVE_THIRD_PARTY_USERS'| 'DISK_THROUGHPUT_GP3'@@ -12465,6 +12562,7 @@ export interface operations {| 'ram_usage'| 'swap_usage'| 'physical_replication_lag_physical_replica_lag_seconds'+ | 'pg_stat_database_num_backends'startDate: stringendDate: stringinterval?: '1m' | '5m' | '10m' | '30m' | '1h' | '1d'@@ -12633,8 +12731,36 @@ export interface operations {}}}+ /** Unpauses project */+ UnpauseController_unpauseProject: {+ parameters: {+ path: {+ /** @description Project ref */+ ref: string+ }+ }+ requestBody: {+ content: {+ 'application/json': components['schemas']['UnpauseProjectBody']+ }+ }+ responses: {+ 201: {+ content: {+ 'application/json': components['schemas']['UnpauseProjectInfo']+ }+ }+ 403: {+ content: never+ }+ /** @description Failed to unpause project */+ 500: {+ content: never+ }+ }+ }/** Cancels a failed restoration */- RestoreController_cancelProjectRestoration: {+ UnpauseController_cancelProjectRestoration: {parameters: {path: {/** @description Project ref */@@ -12656,6 +12782,29 @@ export interface operations {}}}+ /** Retrieves versions to which a project can be restored */+ UnpauseController_getAvailableImageVersions: {+ parameters: {+ path: {+ /** @description Project ref */+ ref: string+ }+ }+ responses: {+ 200: {+ content: {+ 'application/json': components['schemas']['UnpauseProjectAvailableVersionsResponse']+ }+ }+ 403: {+ content: never+ }+ /** @description Failed to retrieve available versions */+ 500: {+ content: never+ }+ }+ }/** Run project lints */ProjectRunLintsController_runProjectLints: {parameters: {