The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): allow creating HA projects (#43809)
Bobbie Soedirgoe7417378ba4d
diff --git a/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsxnew file mode 100644index 00000000000..6c49d90d5f5--- /dev/null+++ b/apps/studio/components/interfaces/ProjectCreation/HighAvailabilityInput.tsx@@ -0,0 +1,47 @@+import Link from 'next/link'+import { UseFormReturn } from 'react-hook-form'++import Panel from 'components/ui/Panel'+import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'+import { FormControl_Shadcn_, FormField_Shadcn_, Switch } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'+import { CreateProjectForm } from './ProjectCreation.schema'++interface HighAvailabilityInputProps {+ form: UseFormReturn<CreateProjectForm>+}++export const HighAvailabilityInput = ({ form }: HighAvailabilityInputProps) => {+ const { hasAccess } = useCheckEntitlements('instances.high_availability')++ if (!hasAccess) return null++ return (+ <Panel.Content>+ <FormField_Shadcn_+ control={form.control}+ name="highAvailability"+ render={({ field }) => (+ <FormItemLayout+ label="High Availability"+ description={+ <>+ Powered by{' '}+ <Link href="https://multigres.com/" target="_blank" className="text-link">+ Multigres+ </Link>+ : horizontally scalable Postgres for multi-tenant, highly available, globally+ distributed deployments while staying true to standard Postgres.+ </>+ }+ layout="horizontal"+ >+ <FormControl_Shadcn_>+ <Switch checked={field.value} onCheckedChange={field.onChange} />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </Panel.Content>+ )+}diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.tsindex a9daa97a7b2..0616efe99ca 100644--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts@@ -12,6 +12,7 @@ export const FormSchema = z.min(1, 'Please enter a project name.') // Required field check.min(3, 'Project name must be at least 3 characters long.') // Minimum length check.max(64, 'Project name must be no longer than 64 characters.'), // Maximum length check+ highAvailability: z.boolean(),postgresVersion: z.string({required_error: 'Please enter a Postgres version.',}),diff --git a/apps/studio/data/projects/project-create-mutation.ts b/apps/studio/data/projects/project-create-mutation.tsindex 894d350cc9e..9c03c9412b3 100644--- a/apps/studio/data/projects/project-create-mutation.ts+++ b/apps/studio/data/projects/project-create-mutation.ts@@ -28,6 +28,7 @@ export type ProjectCreateVariables = {dataApiUseApiSchema?: booleanpostgresEngine?: PostgresEnginereleaseChannel?: ReleaseChannel+ highAvailability?: boolean}export async function createProject({@@ -45,6 +46,7 @@ export async function createProject({dataApiUseApiSchema,postgresEngine,releaseChannel,+ highAvailability,}: ProjectCreateVariables) {const body: CreateProjectBody = {cloud_provider: cloudProvider as CloudProvider,@@ -63,6 +65,7 @@ export async function createProject({data_api_use_api_schema: dataApiUseApiSchema,postgres_engine: postgresEngine,release_channel: releaseChannel,+ high_availability: highAvailability,}const { data, error } = await post(`/platform/projects`, {diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsxindex a259737a578..c75b49554a0 100644--- a/apps/studio/pages/new/[slug].tsx+++ b/apps/studio/pages/new/[slug].tsx@@ -9,6 +9,7 @@ import { CustomPostgresVersionInput } from 'components/interfaces/ProjectCreatioimport { DatabasePasswordInput } from 'components/interfaces/ProjectCreation/DatabasePasswordInput'import { DisabledWarningDueToIncident } from 'components/interfaces/ProjectCreation/DisabledWarningDueToIncident'import { FreeProjectLimitWarning } from 'components/interfaces/ProjectCreation/FreeProjectLimitWarning'+import { HighAvailabilityInput } from 'components/interfaces/ProjectCreation/HighAvailabilityInput'import { OrganizationSelector } from 'components/interfaces/ProjectCreation/OrganizationSelector'import {extractPostgresVersionDetails,@@ -116,6 +117,7 @@ const Wizard: NextPageWithLayout = () => {defaultValues: {organization: slug,projectName: projectName || '',+ highAvailability: false,postgresVersion: '',cloudProvider: PROVIDERS[defaultProvider].id,dbPass: '',@@ -134,6 +136,7 @@ const Wizard: NextPageWithLayout = () => {cloudProvider,dbRegion,organization,+ highAvailability,} = useWatch_Shadcn_({ control: form.control })// [Charis] Since the form is updated in a useEffect, there is an edge case@@ -285,6 +288,7 @@ const Wizard: NextPageWithLayout = () => {const {cloudProvider,projectName,+ highAvailability,dbPass,dbRegion,postgresVersion,@@ -312,6 +316,7 @@ const Wizard: NextPageWithLayout = () => {cloudProvider,organizationSlug: currentOrg.slug,name: projectName,+ highAvailability,// gets ignored due to org billing subscription anywaydbPricingTierId: 'tier_free',// only set the compute size on pro+ plans. Free plans always use micro (nano in the future) size.@@ -429,6 +434,7 @@ const Wizard: NextPageWithLayout = () => {{canCreateProject && (<><ProjectNameInput form={form} />+ <HighAvailabilityInput form={form} />{cloudProviderEnabled && showNonProdFields && (<CloudProviderSelector form={form} />