The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
[MUL-1338] fix(studio): lock compute size to large for HA projects (#49249)
Alaister Youngde4bec77d6a9
diff --git a/apps/studio/components/interfaces/ProjectCreation/ComputeSizeSelector.tsx b/apps/studio/components/interfaces/ProjectCreation/ComputeSizeSelector.tsxindex 49ab883d35f..393d407d52d 100644--- a/apps/studio/components/interfaces/ProjectCreation/ComputeSizeSelector.tsx+++ b/apps/studio/components/interfaces/ProjectCreation/ComputeSizeSelector.tsx@@ -1,3 +1,4 @@+import { useMemo } from 'react'import { UseFormReturn } from 'react-hook-form'import { CloudProvider } from 'shared-data'import {@@ -8,11 +9,12 @@ import {SelectItem,SelectTrigger,SelectValue,+ useWatch,} from 'ui'import { ComputeBadge } from 'ui-patterns/ComputeBadge'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'-import { sizes } from './ProjectCreation.constants'+import { HIGH_AVAILABILITY_INSTANCE_SIZE, sizes } from './ProjectCreation.constants'import { CreateProjectForm } from './ProjectCreation.schema'import { InlineLink } from '@/components/ui/InlineLink'import Panel from '@/components/ui/Panel'@@ -24,6 +26,19 @@ interface ComputeSizeSelectorProps {}export const ComputeSizeSelector = ({ form }: ComputeSizeSelectorProps) => {+ const cloudProvider = useWatch({ control: form.control, name: 'cloudProvider' }) as CloudProvider+ const highAvailability = useWatch({ control: form.control, name: 'highAvailability' })++ const sizeOptions = useMemo(+ () =>+ highAvailability+ ? [HIGH_AVAILABILITY_INSTANCE_SIZE]+ : sizes.filter((option) =>+ instanceSizeSpecs[option].cloud_providers.includes(cloudProvider)+ ),+ [highAvailability, cloudProvider]+ )+return (<Panel.Content><FormField@@ -35,22 +50,23 @@ export const ComputeSizeSelector = ({ form }: ComputeSizeSelectorProps) => {layout="horizontal"label="Compute size"description={- <>- <p>- The size for your dedicated database. You can change this later. Learn more about{' '}- <InlineLink href={`${DOCS_URL}/guides/platform/compute-add-ons`}>- compute add-ons- </InlineLink>{' '}- and{' '}- <InlineLink href={`${DOCS_URL}/guides/platform/manage-your-usage/compute`}>- compute billing- </InlineLink>- .- </p>- </>+ <p>+ The size for your dedicated database. You can change this later. Learn more about{' '}+ <InlineLink href={`${DOCS_URL}/guides/platform/compute-add-ons`}>+ compute add-ons+ </InlineLink>{' '}+ and{' '}+ <InlineLink href={`${DOCS_URL}/guides/platform/manage-your-usage/compute`}>+ compute billing+ </InlineLink>+ .+ </p>}>- <Select value={field.value} onValueChange={(value) => field.onChange(value)}>+ <Select+ value={field.value}+ onValueChange={(value) => value !== '' && field.onChange(value)}+ ><SelectTriggerid="instanceSize"className="[&>span>div>div>[data-field=instance-details]]:hidden"@@ -59,43 +75,39 @@ export const ComputeSizeSelector = ({ form }: ComputeSizeSelectorProps) => {</SelectTrigger><SelectContent><SelectGroup>- {sizes- .filter((option) =>- instanceSizeSpecs[option].cloud_providers.includes(- form.getValues('cloudProvider') as CloudProvider- )- )- .map((option) => {- return (- <SelectItem key={option} value={option}>- <div className="flex flex-row gap-4 items-center">- <div className="w-14 flex items-center">- <ComputeBadge infraComputeSize={option} />- </div>+ {sizeOptions.map((option) => {+ return (+ <SelectItem key={option} value={option}>+ <div className="flex flex-row gap-4 items-center">+ <div className="w-14 flex items-center">+ <ComputeBadge infraComputeSize={option} />+ </div>- <div className="text-sm">- <span className="text-foreground">- {instanceSizeSpecs[option].ram} RAM /{' '}- {instanceSizeSpecs[option].cpu} CPU- </span>- <p- translate="no"- className="text-xs text-foreground-light"- data-field="instance-details"- >- ${instanceSizeSpecs[option].priceHourly}/hour (~$- {instanceSizeSpecs[option].priceMonthly}/month)- </p>- </div>+ <div className="text-sm">+ <span className="text-foreground">+ {instanceSizeSpecs[option].ram} RAM / {instanceSizeSpecs[option].cpu}{' '}+ CPU+ </span>+ <p+ translate="no"+ className="text-xs text-foreground-light"+ data-field="instance-details"+ >+ ${instanceSizeSpecs[option].priceHourly}/hour (~$+ {instanceSizeSpecs[option].priceMonthly}/month)+ </p></div>- </SelectItem>- )- })}- <SelectItem key={'disabled'} value={'disabled'} disabled>- <div className="flex items-center justify-center w-full">- <span>Larger instance sizes available after creation</span>- </div>- </SelectItem>+ </div>+ </SelectItem>+ )+ })}+ {!highAvailability && (+ <SelectItem key={'disabled'} value={'disabled'} disabled>+ <div className="flex items-center justify-center w-full">+ <span>Larger instance sizes available after creation</span>+ </div>+ </SelectItem>+ )}</SelectGroup></SelectContent></Select>diff --git a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsxindex 93b8e7ad0f8..9b619fe1ee8 100644--- a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx+++ b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx@@ -4,6 +4,7 @@ import { type CloudProvider } from 'shared-data'import { Badge, FormControl, FormField, Switch, useWatch } from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'+import { HIGH_AVAILABILITY_INSTANCE_SIZE } from './ProjectCreation.constants'import { CreateProjectForm } from './ProjectCreation.schema'import Panel from '@/components/ui/Panel'import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'@@ -28,10 +29,12 @@ export const HighAvailabilityInput = ({cloudProvider: CloudProvider | undefinedpostgresVersionSelection: string | undefineddbRegion: string | null+ instanceSize: string | null}>({cloudProvider: undefined,postgresVersionSelection: undefined,dbRegion: null,+ instanceSize: null,})const handleHighAvailabilityChange = (checked: boolean) => {@@ -55,6 +58,12 @@ export const HighAvailabilityInput = ({beforeHighAvailability.current.dbRegion = currentRegion ?? nullsetValue('dbRegion', highAvailabilityRegionName)}++ const currentInstanceSize = getValues('instanceSize')+ if (currentInstanceSize !== HIGH_AVAILABILITY_INSTANCE_SIZE) {+ beforeHighAvailability.current.instanceSize = currentInstanceSize ?? null+ setValue('instanceSize', HIGH_AVAILABILITY_INSTANCE_SIZE)+ }} else {if (beforeHighAvailability.current.cloudProvider !== undefined) {setValue('cloudProvider', beforeHighAvailability.current.cloudProvider)@@ -73,6 +82,11 @@ export const HighAvailabilityInput = ({setValue('dbRegion', beforeHighAvailability.current.dbRegion)beforeHighAvailability.current.dbRegion = null}++ if (beforeHighAvailability.current.instanceSize !== null) {+ setValue('instanceSize', beforeHighAvailability.current.instanceSize)+ beforeHighAvailability.current.instanceSize = null+ }}}diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.constants.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.constants.tsindex fb6dcd1d258..6eeb886ce0f 100644--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.constants.ts+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.constants.ts@@ -6,6 +6,7 @@ import type {export const HIGH_AVAILABILITY_POSTGRES_ENGINE = '17' satisfies PostgresEngineexport const HIGH_AVAILABILITY_RELEASE_CHANNEL = 'ga' satisfies ReleaseChannel+export const HIGH_AVAILABILITY_INSTANCE_SIZE: DesiredInstanceSize = 'large'// [Joshen] Obtained from https://gist.github.com/tadast/8827699export const COUNTRY_LAT_LON = {diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.tsindex ec08c1218ef..4f06720b287 100644--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest'import {+ HIGH_AVAILABILITY_INSTANCE_SIZE,HIGH_AVAILABILITY_POSTGRES_ENGINE,HIGH_AVAILABILITY_RELEASE_CHANNEL,} from './ProjectCreation.constants'@@ -10,9 +11,10 @@ import {} from './ProjectCreation.utils'describe('High Availability project creation constraints', () => {- it('pins the Alpha Postgres engine and release channel', () => {+ it('pins the Alpha Postgres engine, release channel, and compute size', () => {expect(HIGH_AVAILABILITY_POSTGRES_ENGINE).toBe('17')expect(HIGH_AVAILABILITY_RELEASE_CHANNEL).toBe('ga')+ expect(HIGH_AVAILABILITY_INSTANCE_SIZE).toBe('large')})it.each([diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsxindex 6ef98e5749d..7b8b4639dc8 100644--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx@@ -371,7 +371,14 @@ export const ProjectCreationForm = ({values.instanceSize &&!sizesWithNoCostConfirmationRequired.includes(values.instanceSize as DesiredInstanceSize)- if (additionalMonthlySpend > 0 && (hasOAuthApps || launchingLargerInstance)) {+ // High availability projects are free during Alpha, so the forced large compute+ // doesn't incur the usual compute costs.+ const requiresCostConfirmation =+ !values.highAvailability &&+ additionalMonthlySpend > 0 &&+ (hasOAuthApps || launchingLargerInstance)++ if (requiresCostConfirmation) {track('project_creation_simple_version_confirm_modal_opened', {instanceSize: values.instanceSize,})diff --git a/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx b/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsxindex 79915d4e6f1..4dbd2b49003 100644--- a/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx+++ b/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx@@ -231,7 +231,11 @@ export const RegionSelector = ({}><FormControl>- <Select value={dbRegion} onValueChange={field.onChange} disabled={isLoading}>+ <Select+ value={dbRegion}+ onValueChange={(value) => value !== '' && field.onChange(value)}+ disabled={isLoading}+ ><SelectTriggerid="region"className="[&>:nth-child(1)]:w-full [&>:nth-child(1)]:flex [&>:nth-child(1)]:items-start"