Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Chore/misc fixes 120324 (#21961)

Joshen Limb74e84d05f6e
diff --git a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
index 0465ac80834..ef37455eb38 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 e41c592b8f1..6bff9f2df27 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 6561f818160..b15193d5c0c 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<ConnectContentTabProps>(
() => import(`./content/${filePath}/content`),
@@ -65,8 +62,11 @@ const ConnectTabContentNew = ({ projectKeys, filePath }: ConnectContentTabProps)
<ContentFile
projectKeys={projectKeys}
filePath={filePath}
- connectionStringPooler={connectionStringPooler}
- connectionStringDirect={connectionStringDirect}
+ connectionStringPooler={{
+ transaction: connectionStringPoolerTransaction,
+ session: connectionStringPoolerSession,
+ }}
+ connectionStringDirect={connectionStringsDirect.uri}
/>
</div>
)
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 9c6a34acf27..dfbcabef0fd 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 (
<ConnectTabs>
<ConnectTabTriggers>
@@ -20,7 +20,7 @@ const ContentFile = ({ connectionStringPooler, connectionStringDirect }: Content
<ConnectTabContent value=".env">
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
-DATABASE_URL="${connectionStringPooler}"
+DATABASE_URL="${connectionStringPooler.transaction}"
`}
</SimpleCodeBlock>
</ConnectTabContent>
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 8ec64311300..5b4098150bf 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 (
<ConnectTabs>
<ConnectTabTriggers>
@@ -20,10 +20,10 @@ const ContentFile = ({ connectionStringPooler, connectionStringDirect }: Content
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
# 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}"
`}
</SimpleCodeBlock>
</ConnectTabContent>
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
index b086d9244ea..d7b7fa7b37a 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"
>
<SidePanel.Content className="flex flex-col py-4 gap-y-8">
- {currentPitrAddon === undefined && (
+ {!isWalgEnabled && (
<Alert_Shadcn_>
<WarningIcon />
<AlertTitle_Shadcn_>