The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): allow compute changes when disk is below 8GB (#45137)
Joey Freelandbc1e5c7760c7
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagement.schema.ts b/apps/studio/components/interfaces/DiskManagement/DiskManagement.schema.tsindex ea31c68a270..3d9250422d8 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagement.schema.ts+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagement.schema.ts@@ -51,9 +51,11 @@ const baseSchema = z.object({export const CreateDiskStorageSchema = ({defaultTotalSize,cloudProvider,+ isSpendCapEnabled,}: {defaultTotalSize: numbercloudProvider: CloudProvider+ isSpendCapEnabled: boolean}) => {const isFlyProject = cloudProvider === 'FLY'const isAwsNimbusProject = cloudProvider === 'AWS_NIMBUS'@@ -69,10 +71,23 @@ export const CreateDiskStorageSchema = ({return COMPUTE_MAX_IOPS[parsedCompute.data] ?? Number.POSITIVE_INFINITY})()- if (validateDiskConfiguration && totalSize < 8) {+ if (validateDiskConfiguration && totalSize < 8 && totalSize !== defaultTotalSize) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: 'Allocated disk size must be at least 8 GB.',+ message: 'New disk size must be at least 8 GB.',+ path: ['totalSize'],+ })+ }++ if (+ validateDiskConfiguration &&+ isSpendCapEnabled &&+ totalSize > 8 &&+ totalSize !== defaultTotalSize+ ) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: 'Disable spend cap to increase disk above 8 GB.',path: ['totalSize'],})}diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsxindex 156e48f8107..94dec479fda 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx@@ -155,6 +155,7 @@ export function DiskManagementForm() {CreateDiskStorageSchema({defaultTotalSize: defaultValues.totalSize,cloudProvider: project?.cloud_provider as CloudProvider,+ isSpendCapEnabled,})),defaultValues,@@ -223,14 +224,15 @@ export function DiskManagementForm() {const isBranch = project?.parent_project_ref !== undefined- const disableDiskInputs =+ const disableDiskSizeInput =isRequestingChanges ||isPlanUpgradeRequired ||isWithinCooldownWindow ||- isSpendCapEnabled ||!canUpdateDiskConfiguration ||!isAws+ const disableDiskInputs = disableDiskSizeInput || isSpendCapEnabled+const disableComputeInputs = isPlanUpgradeRequiredconst isDirty = !!Object.keys(form.formState.dirtyFields).lengthconst isProjectResizing = project?.status === PROJECT_STATUS.RESIZING@@ -383,7 +385,7 @@ export function DiskManagementForm() {{isDiskNoticeVisible && <Separator />}- <SpendCapDisabledSection />+ <SpendCapDisabledSection currentDiskSizeGb={defaultValues.totalSize} /><div className="flex flex-col gap-y-4"><NoticeBar@@ -433,7 +435,7 @@ export function DiskManagementForm() {<DiskSizeFieldform={form}- disableInput={disableDiskInputs}+ disableInput={disableDiskSizeInput}setAdvancedSettingsOpenState={setAdvancedSettingsOpenState}/></>diff --git a/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx b/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsxindex c12bcdd0d0c..2c9f9d0b1ee 100644--- a/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx+++ b/apps/studio/components/interfaces/DiskManagement/fields/AutoScaleFields.tsx@@ -44,7 +44,7 @@ export const AutoScaleFields = ({ form }: AutoScaleFieldProps) => {200)- const totalSizeAfterGrowth = autoscaleGrowValue + totalSize+ const totalSizeAfterGrowth = Math.max(autoscaleGrowValue + totalSize, 8)const formattedTotalSizeAfterGrowth =totalSizeAfterGrowth < _maxSizeGb ? totalSizeAfterGrowth : _maxSizeGbconst formattedGrowValue = formattedTotalSizeAfterGrowth - totalSizediff --git a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsxindex 296df80f45f..e31eaf571c1 100644--- a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx+++ b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx@@ -149,7 +149,7 @@ export function DiskSizeField({<span className="text-foreground-lighter text-sm">{includedDiskGB > 0 &&org?.plan.id &&- `Your plan includes ${includedDiskGB} GB of disk size for ${watchedStorageType}.`}+ `Your plan includes up to ${includedDiskGB} GB of ${watchedStorageType} storage.`}<div className="mt-3"><DocsButton abbrev={false} href={`${DOCS_URL}/guides/platform/database-size`} />diff --git a/apps/studio/components/interfaces/DiskManagement/ui/SpendCapDisabledSection.tsx b/apps/studio/components/interfaces/DiskManagement/ui/SpendCapDisabledSection.tsxindex 593a3cd6800..da0dcef08cc 100644--- a/apps/studio/components/interfaces/DiskManagement/ui/SpendCapDisabledSection.tsx+++ b/apps/studio/components/interfaces/DiskManagement/ui/SpendCapDisabledSection.tsx@@ -11,7 +11,11 @@ import { Admonition } from 'ui-patterns/admonition'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-export function SpendCapDisabledSection() {+interface SpendCapDisabledSectionProps {+ currentDiskSizeGb?: number+}++export function SpendCapDisabledSection({ currentDiskSizeGb }: SpendCapDisabledSectionProps) {const { data: org, isPending: isOrgPending } = useSelectedOrganizationQuery()const { data: project, isPending: isProjectPending } = useSelectedProjectQuery()@@ -22,6 +26,12 @@ export function SpendCapDisabledSection() {!org?.usage_billing_enabled &&project?.cloud_provider !== 'FLY'+ const showAutoExpandNotice =+ isSpendCapEnabled &&+ currentDiskSizeGb !== undefined &&+ currentDiskSizeGb > 0 &&+ currentDiskSizeGb < 8+return (<AnimatePresence>{isSpendCapEnabled && (@@ -30,12 +40,23 @@ export function SpendCapDisabledSection() {animate={{ opacity: 1, height: 'auto' }}exit={{ opacity: 0, height: 0 }}transition={{ duration: 0.2 }}+ className="flex flex-col gap-3">+ {showAutoExpandNotice && (+ <Admonition type="default">+ <AlertTitle>Your disk will auto-expand to 8 GB</AlertTitle>+ <AlertDescription>+ The first time your database usage triggers a resize, your disk will automatically+ expand to at least 8 GB. You don't need to disable spend cap or do anything+ manually for this to happen.+ </AlertDescription>+ </Admonition>+ )}<Admonition type="default">- <AlertTitle>Disable spend cap to manage Disk configuration</AlertTitle>+ <AlertTitle>Spend cap limits disk size to 8 GB</AlertTitle><AlertDescription>- To access disk management features, you need to disable your spend cap. These features- offer more flexibility and control over your database disk size.+ You can resize your disk up to 8 GB with spend cap enabled. To expand beyond 8 GB or+ configure IOPS, throughput, and storage type, disable your spend cap.</AlertDescription><div className="mt-3"><Link