Skip to content

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

fix(studio): price nano compute at the micro rate in restore to new project (#50546)

Ali Waseem45a80b56856f
diff --git a/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.test.ts b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.test.ts
new file mode 100644
index 00000000000..72422a069c5
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from 'vitest'
+
+import { projectSpecToMonthlyPrice } from './RestoreToNewProject.utils'
+import { InfraInstanceSize } from '@/components/interfaces/DiskManagement/DiskManagement.types'
+import { DiskType } from '@/components/interfaces/DiskManagement/ui/DiskManagement.constants'
+import { PlanId } from '@/data/subscriptions/types'
+
+const getComputePrice = (targetComputeSize: InfraInstanceSize, planId: PlanId) =>
+ projectSpecToMonthlyPrice({
+ targetVolumeSizeGb: 8,
+ targetComputeSize,
+ planId,
+ storageType: DiskType.GP3,
+ }).computePrice
+
+describe('projectSpecToMonthlyPrice', () => {
+ it('prices nano at the micro rate on paid plans', () => {
+ expect(getComputePrice('nano', 'pro')).toBe(9.68)
+ expect(getComputePrice('nano', 'team')).toBe(9.68)
+ })
+
+ it('prices pico at the micro rate on paid plans', () => {
+ expect(getComputePrice('pico', 'pro')).toBe(9.68)
+ })
+
+ it('prices nano and pico at zero on the free plan', () => {
+ expect(getComputePrice('nano', 'free')).toBe(0)
+ expect(getComputePrice('pico', 'free')).toBe(0)
+ })
+
+ it('prices sizes above nano from their own compute rate', () => {
+ expect(getComputePrice('micro', 'pro')).toBe(9.68)
+ expect(getComputePrice('small', 'pro')).toBe(14.83)
+ })
+})
diff --git a/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.ts b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.ts
index a27a42288ed..d33f955d033 100644
--- a/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.ts
+++ b/apps/studio/components/interfaces/Database/Backups/RestoreToNewProject/RestoreToNewProject.utils.ts
@@ -42,7 +42,7 @@ export function projectSpecToMonthlyPrice({
const computePrice = calculateComputeSizePrice({
availableOptions: [
- { identifier: targetComputeSize, price: getComputeHourlyPrice(targetComputeSize) },
+ { identifier: targetComputeSize, price: getComputeHourlyPrice(targetComputeSize, planId) },
],
oldComputeSize: 'nano', // not used for r2np
newComputeSize: targetComputeSize,
@@ -55,9 +55,9 @@ export function projectSpecToMonthlyPrice({
}
}
-function getComputeHourlyPrice(computeSize: InfraInstanceSize): number {
+function getComputeHourlyPrice(computeSize: InfraInstanceSize, planId: PlanId): number {
if (computeSize === 'pico' || computeSize === 'nano') {
- return 0
+ return planId === 'free' ? 0 : instanceSizeSpecs.micro.priceHourly
}
return instanceSizeSpecs[computeSize]?.priceHourly