The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/update db connection string kaizen 2 (#20621)
Joshen Limd76c46cc4292
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsxindex d728f2e2299..40cb5bac8b7 100644--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx@@ -192,7 +192,7 @@ export const DatabaseConnectionString = () => {<div className="flex flex-col gap-y-1 text-foreground-light"><p className="text-sm">You can use the following URI format to switch to a different database or user- when using connection pooling.+ {usePoolerConnection ? ' when using connection pooling' : ''}.</p><p className="text-sm font-mono tracking-tight text-foreground-lighter">{poolerConnStringSyntax.map((x, idx) => {diff --git a/apps/studio/components/interfaces/Settings/Database/UsePoolerCheckbox.tsx b/apps/studio/components/interfaces/Settings/Database/UsePoolerCheckbox.tsxindex 466b3c71898..8a3a7b2c292 100644--- a/apps/studio/components/interfaces/Settings/Database/UsePoolerCheckbox.tsx+++ b/apps/studio/components/interfaces/Settings/Database/UsePoolerCheckbox.tsx@@ -3,6 +3,7 @@ import { Badge, Checkbox_Shadcn_ } from 'ui'import { Markdown } from 'components/interfaces/Markdown'import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'+import { useProjectSettingsQuery } from 'data/config/project-settings-query'interface UsePoolerCheckboxInterface {id: string@@ -13,9 +14,9 @@ interface UsePoolerCheckboxInterface {export const UsePoolerCheckbox = ({ id, checked, onCheckedChange }: UsePoolerCheckboxInterface) => {const { ref: projectRef } = useParams()const { data, isSuccess } = usePoolingConfigurationQuery({ projectRef })+ const { data: settings, isSuccess: isSuccessSettings } = useProjectSettingsQuery({ projectRef })- // [Joshen] TODO this needs to be obtained from BE as 26th Jan is when we'll start - projects will be affected at different rates- const resolvesToIpV6 = !data?.supavisor_enabled && false // Number(new Date()) > Number(dayjs.utc('01-26-2024', 'MM-DD-YYYY').toDate())+ const resolvesToIpV6 = !data?.supavisor_enabled && settings?.project.db_ip_addr_config === 'ipv6'return (<div className="flex gap-x-3">@@ -32,13 +33,15 @@ export const UsePoolerCheckbox = ({ id, checked, onCheckedChange }: UsePoolerCheSupavisor</Badge>)}- <Badge color="scale" className="ml-2">- {checked- ? 'Resolves to IPv4'- : resolvesToIpV6- ? 'Resolves to IPv6'- : 'Resolves to IPv4'}- </Badge>+ {isSuccessSettings && (+ <Badge color="scale" className="ml-2">+ {checked+ ? 'Resolves to IPv4'+ : resolvesToIpV6+ ? 'Resolves to IPv6'+ : 'Will resolve to IPv6'}+ </Badge>+ )}</label><MarkdownextLinksdiff --git a/apps/studio/data/api.d.ts b/apps/studio/data/api.d.tsindex c348c55a554..b746c68aa90 100644--- a/apps/studio/data/api.d.ts+++ b/apps/studio/data/api.d.ts@@ -1764,13 +1764,8 @@ export interface components {actions?: components['schemas']['NotificationAction'][]}NotificationResponseV2: {- /** @enum {string} */- type:- | 'project.tier-limit-exceeded'- | 'postgresql.upgrade-available'- | 'postgresql.upgrade-completed'- | 'project.update-completed'- | 'project.informational'+ /** @deprecated */+ type: string | null/** @enum {string} */status: 'new' | 'seen' | 'archived'/** @enum {string} */@@ -4550,7 +4545,7 @@ export interface components {ipv4_addresses: string[]}NetworkRestrictionsRequest: {- dbAllowedCidrs: string[]+ dbAllowedCidrs?: string[]dbAllowedCidrsV6?: string[]}NetworkRestrictionsResponse: {@@ -4815,15 +4810,16 @@ export interface components {is_physical_backup: booleaninserted_at: string}+ PhysicalBackup: {+ earliest_physical_backup_date_unix?: number+ latest_physical_backup_date_unix?: number+ }V1BackupsResponse: {region: stringwalg_enabled: booleanpitr_enabled: booleanbackups: components['schemas']['V1Backup'][]- physical_backup_data: {- earliest_physical_backup_date_unix?: number- latest_physical_backup_date_unix?: number- }+ physical_backup_data: components['schemas']['PhysicalBackup']}V1RestorePitrBody: {recovery_time_target_unix: numberdiff --git a/apps/studio/data/config/project-settings-query.ts b/apps/studio/data/config/project-settings-query.tsindex a85ef8debe7..34eb332caf5 100644--- a/apps/studio/data/config/project-settings-query.ts+++ b/apps/studio/data/config/project-settings-query.ts@@ -1,79 +1,52 @@import { useQuery, UseQueryOptions } from '@tanstack/react-query'-import { get } from 'lib/common/fetch'+import { get } from 'data/fetchers'import { API_URL, DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'import { configKeys } from './keys'import { ResponseError } from 'types'+import { components } from 'data/api'export type ProjectSettingsVariables = {projectRef?: string}-export type Project = {- id: number- name: string- ref: string- status: string+// [Joshen] API typing needs to be fixed - this is completely wrong+type ProjectSettingsInfo = components['schemas']['SettingsResponse']['project']+interface ProjectSettingsInfoExtended extends ProjectSettingsInfo {+ cloud_provider: stringinserted_at: stringdb_dns_name: string- db_port: number+ db_host: stringdb_name: string+ db_port: numberdb_ssl: boolean- db_host: stringdb_user: string- cloud_provider: string- region: string- services: Service[]jwt_secret: string+ ref: string+ status: string+ // [Joshen] Based on the enums here+ // https://github.com/supabase/infrastructure/blob/95dc09fe077dba7817bb112fa72b6814a620ecd3/shared/src/projects.ts#L177+ db_ip_addr_config: 'legacy' | 'static-ipv4' | 'concurrent-ipv6' | 'ipv6'}-export type Service = {- id: number- name: string- app_config: AppConfig- app: App- service_api_keys: ServiceApiKey[]-}--export type AppConfig = {- protocol: 'https' | 'http'- endpoint: string- db_schema: string- realtime_multitenant_enabled: boolean-}--export type App = {- id: number- name: string-}--export type ServiceApiKey = {- api_key_encrypted: string- tags: string- name: string- api_key: string-}--export type ProjectSettingsResponse = {- project: Project- services: Service[]+export type ProjectSettings = {+ project: ProjectSettingsInfoExtended+ services: components['schemas']['SettingsResponse']['services']}export async function getProjectSettings({ projectRef }: ProjectSettingsVariables,signal?: AbortSignal) {- if (!projectRef) {- throw new Error('projectRef is required')- }+ if (!projectRef) throw new Error('projectRef is required')- const response = await get(`${API_URL}/props/project/${projectRef}/settings`, {+ // [Joshen] API typing is wrong here+ const { data, error } = await get('/platform/props/project/{ref}/settings', {+ params: { path: { ref: projectRef } },signal,})- if (response.error) {- throw response.error- }- return response as ProjectSettingsResponse+ if (error) throw error+ return data as unknown as ProjectSettings}export type ProjectSettingsData = Awaited<ReturnType<typeof getProjectSettings>>@@ -91,10 +64,10 @@ export const useProjectSettingsQuery = <TData = ProjectSettingsData>(({ signal }) => getProjectSettings({ projectRef }, signal),{enabled: enabled && typeof projectRef !== 'undefined',- refetchInterval(data, query) {- const apiService = (- (data as unknown as ProjectSettingsData | undefined)?.services ?? []- ).find((x) => x.app.id == DEFAULT_PROJECT_API_SERVICE_ID)+ refetchInterval(data) {+ const apiService = ((data as ProjectSettings)?.services ?? []).find(+ (x) => x.app.id == DEFAULT_PROJECT_API_SERVICE_ID+ )const apiKeys = apiService?.service_api_keys ?? []const interval = apiKeys.length === 0 ? 2000 : 0