Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/misc fixes 120324 #21961

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface ContentFileProps {
apiUrl: string
anonKey: string
}
connectionStringPooler: string
connectionStringPooler: {
transaction: string
session: string
}
connectionStringDirect: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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`),
Expand All @@ -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>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 })

Expand All @@ -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 ?? []
Expand Down Expand Up @@ -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_>
Expand Down