diff --git a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx index 0465ac80834de..ef37455eb3838 100644 --- a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx +++ b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx @@ -162,6 +162,9 @@ export const AIPolicyEditorPanel = memo(function ({ sql: policy, projectRef: selectedProject?.ref, connectionString: selectedProject?.connectionString, + handleError: (error) => { + throw error + }, }) } }, [executeMutation, selectedProject?.connectionString, selectedProject?.ref]) diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.types.ts b/apps/studio/components/interfaces/Home/Connect/Connect.types.ts index e41c592b8f182..6bff9f2df2752 100644 --- a/apps/studio/components/interfaces/Home/Connect/Connect.types.ts +++ b/apps/studio/components/interfaces/Home/Connect/Connect.types.ts @@ -8,6 +8,9 @@ export interface ContentFileProps { apiUrl: string anonKey: string } - connectionStringPooler: string + connectionStringPooler: { + transaction: string + session: string + } connectionStringDirect: string } diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx index 6561f818160db..b15193d5c0c5d 100644 --- a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx +++ b/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx @@ -11,7 +11,10 @@ import type { projectKeys } from './Connect.types' interface ConnectContentTabProps { projectKeys: projectKeys filePath: string - connectionStringPooler?: string + connectionStringPooler?: { + transaction: string + session: string + } connectionStringDirect?: string } @@ -40,14 +43,8 @@ const ConnectTabContentNew = ({ projectKeys, filePath }: ConnectContentTabProps) usePoolerConnection: false, }) : { uri: '' } - const connectionStringPooler = - filePath !== 'drizzle' - ? connectionStringsPooler.uri.replace('6543', '5432') - : connectionStringsPooler.uri - const connectionStringDirect = - filePath !== 'drizzle' - ? connectionStringsDirect.uri.replace('6543', '5432') - : connectionStringsDirect.uri + const connectionStringPoolerTransaction = connectionStringsPooler.uri + const connectionStringPoolerSession = connectionStringsPooler.uri.replace('6543', '5432') const ContentFile = dynamic( () => import(`./content/${filePath}/content`), @@ -65,8 +62,11 @@ const ConnectTabContentNew = ({ projectKeys, filePath }: ConnectContentTabProps) ) diff --git a/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx b/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx index 9c6a34acf273f..dfbcabef0fdb7 100644 --- a/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx +++ b/apps/studio/components/interfaces/Home/Connect/content/drizzle/content.tsx @@ -8,7 +8,7 @@ import { } from 'components/interfaces/Home/Connect/ConnectTabs' import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock' -const ContentFile = ({ connectionStringPooler, connectionStringDirect }: ContentFileProps) => { +const ContentFile = ({ connectionStringPooler }: ContentFileProps) => { return ( @@ -20,7 +20,7 @@ const ContentFile = ({ connectionStringPooler, connectionStringDirect }: Content {` -DATABASE_URL="${connectionStringPooler}" +DATABASE_URL="${connectionStringPooler.transaction}" `} diff --git a/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx b/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx index 8ec6431130031..5b4098150bf6d 100644 --- a/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx +++ b/apps/studio/components/interfaces/Home/Connect/content/prisma/content.tsx @@ -8,7 +8,7 @@ import { } from 'components/interfaces/Home/Connect/ConnectTabs' import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock' -const ContentFile = ({ connectionStringPooler, connectionStringDirect }: ContentFileProps) => { +const ContentFile = ({ connectionStringPooler }: ContentFileProps) => { return ( @@ -20,10 +20,10 @@ const ContentFile = ({ connectionStringPooler, connectionStringDirect }: Content {` # Connect to Supabase via connection pooling with Supavisor. -DATABASE_URL="${connectionStringPooler}" +DATABASE_URL="${connectionStringPooler.transaction}" # Direct connection to the database. Used for migrations. -DIRECT_URL="${connectionStringDirect}" +DIRECT_URL="${connectionStringPooler.session}" `} diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx index b086d9244ea29..d7b7fa7b37a29 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx @@ -19,6 +19,7 @@ import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import { useSelectedOrganization, useSelectedProject } from 'hooks' import { AWS_REGIONS, AWS_REGIONS_DEFAULT, AWS_REGIONS_KEYS, BASE_PATH } from 'lib/constants' import { AVAILABLE_REPLICA_REGIONS, AWS_REGIONS_VALUES } from './InstanceConfiguration.constants' +import { useBackupsQuery } from 'data/database/backups-query' // [Joshen] FYI this is purely for AWS only, need to update to support Fly eventually @@ -40,6 +41,7 @@ const DeployNewReplicaPanel = ({ const org = useSelectedOrganization() const { data } = useReadReplicasQuery({ projectRef }) + const { data: backups } = useBackupsQuery({ projectRef }) const { data: addons, isSuccess } = useProjectAddonsQuery({ projectRef }) const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug }) @@ -58,17 +60,17 @@ const DeployNewReplicaPanel = ({ const reachedMaxReplicas = (data ?? []).filter((db) => db.identifier !== projectRef).length >= 2 const isFreePlan = subscription?.plan.id === 'free' + const isWalgEnabled = backups?.walg_enabled const currentComputeAddon = addons?.selected_addons.find( (addon) => addon.type === 'compute_instance' ) - const currentPitrAddon = addons?.selected_addons.find((addon) => addon.type === 'pitr') const canDeployReplica = !reachedMaxReplicas && currentPgVersion >= 15 && project?.cloud_provider === 'AWS' && !isFreePlan && - currentComputeAddon !== undefined && - currentPitrAddon !== undefined + isWalgEnabled && + currentComputeAddon !== undefined const computeAddons = addons?.available_addons.find((addon) => addon.type === 'compute_instance')?.variants ?? [] @@ -122,7 +124,7 @@ const DeployNewReplicaPanel = ({ header="Deploy a new read replica" > - {currentPitrAddon === undefined && ( + {!isWalgEnabled && (