The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): limit DuckLake managed setup to the current project (#51380)
Coenen Benjamin853bac960e5d
diff --git a/apps/docs/content/guides/database/replication/pipelines/ducklake.mdx b/apps/docs/content/guides/database/replication/pipelines/ducklake.mdxindex d6ff3179cd8..44aef146fe8 100644--- a/apps/docs/content/guides/database/replication/pipelines/ducklake.mdx+++ b/apps/docs/content/guides/database/replication/pipelines/ducklake.mdx@@ -16,7 +16,12 @@ Insert-only tables don't require a primary key or replica identity. Updates and## Prepare DuckLake resources [#understand-the-ducklake-components]-DuckLake stores metadata in a Postgres catalog and data in object storage. With **Select Supabase projects**, choose a project for the catalog, then a project and bucket for storage. The catalog and storage can use the same project. Pipelines creates the connection credentials. With **Enter connection details**, you provide the catalog URL and storage credentials. You also need a compatible query engine to read the replicated data.+DuckLake stores metadata in a Postgres catalog and data in object storage. Pipelines offers two ways to set them up:++- **Use this Supabase project**: Pipelines uses this project's Postgres database as the catalog and a Storage bucket in the same project as object storage. It also creates the connection credentials.+- **Enter connection details**: You provide the catalog URL and the storage credentials.++To read the replicated data, you also need a compatible query engine.| Component | Purpose || ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |@@ -30,27 +35,24 @@ You can query replicated tables, but treat them and their underlying catalog andFollow [Set up Pipelines](/docs/guides/database/replication/pipelines#setup-overview). In **Add pipeline**, select **DuckLake**, enter a **Pipeline name**, choose a **Publication**, and set **Initial sync**. Then choose how to configure the catalog and storage.-### Select Supabase projects [#use-supabase]+### Use this Supabase project [#use-supabase]-Choose Supabase projects for the Postgres catalog and Storage bucket. Pipelines creates the connection credentials when you create the destination.+Use the current Supabase project's Postgres database for the catalog and a Storage bucket in the same project. Pipelines creates the connection credentials when you create the destination.Before you begin:-- Choose active, healthy, non-branch projects from the same organization for the catalog and storage. You can use the same project for both.-- Make sure your organization role can administer SQL in the catalog project and Storage in the storage project.- Choose a Files bucket for DuckLake data. You can create a private bucket from the destination form.-- Choose an unused metadata schema name for this DuckLake. Pipelines creates the schema and its tables. Use only letters, numbers, and underscores. If the catalog project already uses the default `ducklake` schema for Warehouse, enter a different name.-- Keep catalog and storage in the same region when possible, near the [managed pipeline region](/docs/guides/database/replication/pipelines#region).+- Choose an unused metadata schema name for this DuckLake. Pipelines creates the schema and its tables. Use only letters, numbers, and underscores. If the project already uses the default `ducklake` schema for Warehouse, enter a different name.To configure the destination:-1. Select **Select Supabase projects** under **Configuration method**.-2. Choose the **Catalog project** and **Metadata schema**.-3. Choose the **Storage project** and **Bucket**. Select **New bucket** at the bottom of the bucket list if you haven't created one yet.+1. Select **Use this Supabase project** under **Configuration method**.+2. Enter the **Metadata schema**.+3. Choose the **Bucket**. Select **New bucket** at the bottom of the bucket list if you haven't created one yet.4. Optionally adjust **Pool size** under **Advanced settings**. It allows 1 to 6 concurrent DuckDB connections; the default is 4.5. Click **Start pipeline**. Review any validation warnings, then confirm the estimated cost with **Create and start pipeline**.-Credential-provisioning warnings are expected before creation: catalog and Storage credentials are provisioned when you save the destination. Review the selected resources before proceeding.+Credential-provisioning warnings are expected before creation: catalog and Storage credentials are provisioned when you save the destination. Review the metadata schema and bucket before proceeding.### Enter connection details [#custom-parameters]@@ -62,7 +64,7 @@ Prepare the following resources:2. An S3-compatible bucket and a dedicated prefix for this DuckLake.3. Object-storage credentials that can list, read, write, and delete objects under that prefix. Delete access is required for managed file cleanup.-Choose an unused metadata schema name and a new data prefix for each destination. Pipelines creates the schema and its tables. Initialising a DuckLake catalog in that schema beforehand triggers a validation warning; reusing its schema or prefix can mix metadata or files from different DuckLakes.+Choose an unused metadata schema name and a new data prefix for each destination. Pipelines creates the schema and its tables. Initializing a DuckLake catalog in that schema beforehand triggers a validation warning; reusing its schema or prefix can mix metadata or files from different DuckLakes.Select **Enter connection details** under **Configuration method**, then configure these fields:@@ -91,7 +93,7 @@ A source `TRUNCATE` truncates the DuckLake table. A [table restart](/docs/guidesConnect DuckDB with its `ducklake` extension, or another compatible engine, to the same catalog and storage path. Query through the catalog; reading raw Parquet files can miss inlined changes, delete files, and the current snapshot.-If you selected Supabase projects, create separate read credentials for the catalog and Storage projects. The writer credentials generated for Pipelines aren't exposed. If you entered connection details, use separate read-only credentials when your catalog and storage provider support them.+If you use this Supabase project, create separate read credentials for its Postgres database and Storage. The writer credentials generated for Pipelines aren't exposed. If you enter connection details, use separate read-only credentials when your catalog and storage provider support them.After attaching the catalog under an alias such as `my_ducklake`, source schemas and tables are available as qualified DuckLake tables:@@ -161,7 +163,7 @@ For type changes, unsupported changes, and interrupted schema changes, see the s| Issue | Resolution || ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Credential-provisioning warnings | Expected when you [select Supabase projects](#use-supabase) before saving. Review the selected resources. |+| Credential-provisioning warnings | Expected when you [use this Supabase project](#use-supabase) before saving. Review the metadata schema and bucket. || Catalog or storage validation fails | Check the [connection details](#custom-parameters), credentials, connectivity, and permissions for the configured prefix. Local `file://` paths are unsupported. || Metadata schema exists | Choose a new schema, unless intentionally reusing the same DuckLake and its corresponding data path. || Inserts work but updates or deletes fail | Check [replica identity and published columns](#source-table-requirements). |diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.test.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.test.tsindex d21f4478114..d973afbc14b 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.test.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.test.ts@@ -504,13 +504,11 @@ describe('DestinationForm.utils DuckLake', () => {const baseDucklakeSupabaseFormData = {...baseDucklakeFormData,ducklakeMode: 'supabase' as const,- ducklakeCatalogProjectRef: 'catalog-ref',- ducklakeStorageProjectRef: 'storage-ref',ducklakeStorageBucket: 'ducklake-data',}-describe('DestinationForm.utils DuckLake (Use Supabase)', () => {- it('builds DuckLake validation config from project refs in supabase mode', () => {+describe('DestinationForm.utils DuckLake (managed)', () => {+ it('uses the current project for the catalog and storage during validation', () => {const config = buildDestinationConfigForValidation({projectRef: 'project-ref',selectedType: 'DuckLake',@@ -519,8 +517,8 @@ describe('DestinationForm.utils DuckLake (Use Supabase)', () => {expect(config).toEqual({ducklake: {- catalogProjectRef: 'catalog-ref',- storageProjectRef: 'storage-ref',+ catalogProjectRef: 'project-ref',+ storageProjectRef: 'project-ref',bucket: 'ducklake-data',poolSize: 4,metadataSchema: 'ducklake_metadata',@@ -528,7 +526,7 @@ describe('DestinationForm.utils DuckLake (Use Supabase)', () => {})})- it('builds DuckLake submit config from project refs in supabase mode', async () => {+ it('uses the current project for the catalog and storage during submission', async () => {const createS3AccessKey = vi.fn()const resolveNamespace = vi.fn()@@ -542,8 +540,8 @@ describe('DestinationForm.utils DuckLake (Use Supabase)', () => {expect(config).toEqual({ducklake: {- catalogProjectRef: 'catalog-ref',- storageProjectRef: 'storage-ref',+ catalogProjectRef: 'project-ref',+ storageProjectRef: 'project-ref',bucket: 'ducklake-data',poolSize: 4,metadataSchema: 'ducklake_metadata',@@ -553,11 +551,9 @@ describe('DestinationForm.utils DuckLake (Use Supabase)', () => {expect(resolveNamespace).not.toHaveBeenCalled()})- it('returns required-field errors for missing supabase selections, ignoring custom fields', () => {+ it('requires a bucket and ignores connection fields', () => {const issues = getDucklakeValidationIssues({ducklakeMode: 'supabase',- ducklakeCatalogProjectRef: '',- ducklakeStorageProjectRef: '',ducklakeStorageBucket: '',// Custom-mode fields are intentionally blank and must not be validated in supabase modeducklakeCatalogUrl: '',@@ -569,19 +565,13 @@ describe('DestinationForm.utils DuckLake (Use Supabase)', () => {ducklakeMetadataSchema: '',})- expect(issues).toEqual([- { path: 'ducklakeCatalogProjectRef', message: 'Catalog project is required.' },- { path: 'ducklakeStorageProjectRef', message: 'Storage project is required.' },- { path: 'ducklakeStorageBucket', message: 'Bucket is required.' },- ])+ expect(issues).toEqual([{ path: 'ducklakeStorageBucket', message: 'Bucket is required.' }])})- it('accepts a complete supabase configuration', () => {+ it('accepts a complete managed configuration', () => {expect(getDucklakeValidationIssues({ducklakeMode: 'supabase',- ducklakeCatalogProjectRef: 'catalog-ref',- ducklakeStorageProjectRef: 'storage-ref',ducklakeStorageBucket: 'ducklake-data',ducklakeCatalogUrl: '',ducklakeDataPath: '',diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.tsindex 007201431d8..7a33f34f8d5 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationForm.utils.ts@@ -66,14 +66,12 @@ export const generateDefaultValues = ({pipelineData,catalogToken,region,- projectRef,editMode,}: {destinationData?: ReplicationDestinationByIdDatapipelineData?: ReplicationPipelineByIdDatacatalogToken: stringregion?: string- projectRef?: stringeditMode: boolean}): DestinationPanelSchemaType => {const config = destinationData?.config@@ -131,12 +129,10 @@ export const generateDefaultValues = ({s3SecretAccessKey: '',s3Region: region ?? icebergConfig?.s3_region ?? '',// DuckLake fields- // New destinations default to the managed "Use Supabase" mode with the current project- // pre-selected as both catalog and storage. Existing destinations always read back as the- // resolved/custom shape, so edit mode is locked to "Custom parameters".+ // New destinations default to the managed mode, which keeps the catalog and storage in the+ // current project. Existing destinations always read back as the resolved/custom shape, so+ // edit mode is locked to custom connection details.ducklakeMode: (editMode ? DUCKLAKE_MODE_CUSTOM : DUCKLAKE_MODE_SUPABASE) as DucklakeMode,- ducklakeCatalogProjectRef: editMode ? '' : (projectRef ?? ''),- ducklakeStorageProjectRef: editMode ? '' : (projectRef ?? ''),ducklakeStorageBucket: '',ducklakeCatalogUrl: ducklakeConfig?.catalog_url ?? '',ducklakeDataPath: ducklakeConfig?.data_path ?? '',@@ -322,15 +318,15 @@ const buildClickHouseConfig = (engine: data.clickhouseEngine,})-// Builds the studio-side DuckLake config from form data, picking the right shape for the-// selected mode. The create / update / validate mutations convert this to the API payload.+// Managed mode always uses the current project for both the catalog and storage.const buildDucklakeConfig = (- data: z.infer<typeof DestinationPanelFormSchema>+ data: z.infer<typeof DestinationPanelFormSchema>,+ projectRef: string): DucklakeDestinationConfig => {if (data.ducklakeMode === DUCKLAKE_MODE_SUPABASE) {const supabaseConfig: DucklakeSupabaseDestinationConfig = {- catalogProjectRef: normalizeRequiredString(data.ducklakeCatalogProjectRef),- storageProjectRef: normalizeRequiredString(data.ducklakeStorageProjectRef),+ catalogProjectRef: projectRef,+ storageProjectRef: projectRef,bucket: normalizeRequiredString(data.ducklakeStorageBucket),poolSize: data.ducklakePoolSize === '' ? undefined : data.ducklakePoolSize,metadataSchema: normalizeOptionalString(data.ducklakeMetadataSchema),@@ -393,7 +389,7 @@ export const buildDestinationConfigForValidation = ({},}} else if (selectedType === 'DuckLake') {- return { ducklake: buildDucklakeConfig(data) }+ return { ducklake: buildDucklakeConfig(data, projectRef) }} else if (selectedType === 'Snowflake') {return { snowflake: buildSnowflakeConfig(data) }} else if (selectedType === 'ClickHouse') {@@ -454,7 +450,7 @@ export const buildDestinationConfig = async ({}destinationConfig = { iceberg: icebergConfig }} else if (selectedType === 'DuckLake') {- destinationConfig = { ducklake: buildDucklakeConfig(data) }+ destinationConfig = { ducklake: buildDucklakeConfig(data, projectRef) }} else if (selectedType === 'Snowflake') {destinationConfig = { snowflake: buildSnowflakeConfig(data) }} else if (selectedType === 'ClickHouse') {diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationFormFieldCopy.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationFormFieldCopy.tsindex d264964e23e..4f42eb2277f 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationFormFieldCopy.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DestinationFormFieldCopy.ts@@ -23,16 +23,6 @@ export const ANALYTICS_BUCKET_NAMESPACE_FIELD_COPY = {description: 'The namespace within the bucket where tables will be organized.',} as const-export const DUCKLAKE_CATALOG_PROJECT_FIELD_COPY = {- label: 'Catalog project',- description: 'Postgres project that stores this DuckLake’s metadata.',-} as const--export const DUCKLAKE_STORAGE_PROJECT_FIELD_COPY = {- label: 'Storage project',- description: 'Supabase project that stores the DuckLake data files.',-} as const-export const DUCKLAKE_BUCKET_FIELD_COPY = {label: 'Bucket',description: 'Files bucket for DuckLake data.',diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.constants.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.constants.tsindex bf55494b6b3..bb80a3f6419 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.constants.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.constants.ts@@ -1,5 +1,5 @@-// DuckLake can either be backed by Supabase projects (catalog + storage are managed for the-// user) or configured manually with a PostgreSQL catalog URL and S3-compatible credentials.+// DuckLake can use the current project for managed catalog and storage, or connect to an existing+// Postgres catalog and S3-compatible storage.export const DUCKLAKE_MODE_SUPABASE = 'supabase'export const DUCKLAKE_MODE_CUSTOM = 'custom'export type DucklakeMode = typeof DUCKLAKE_MODE_SUPABASE | typeof DUCKLAKE_MODE_CUSTOMdiff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.schema.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.schema.tsindex e78683d1e3e..2c06d6e25e5 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.schema.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.schema.ts@@ -1,14 +1,12 @@import * as z from 'zod'-// `supabase` mode picks Supabase projects for catalog + storage (managed), while `custom`-// mode keeps the manual PostgreSQL catalog URL + S3-compatible credentials.+// `supabase` mode uses the current project for managed catalog and storage. `custom` mode connects+// to an existing Postgres catalog and S3-compatible storage.export const DuckLakeFormSchema = z.object({ducklakeMode: z.enum(['supabase', 'custom']).optional(),- // DuckLake "Use Supabase" fields- ducklakeCatalogProjectRef: z.string().optional(),- ducklakeStorageProjectRef: z.string().optional(),+ // Managed DuckLake fieldsducklakeStorageBucket: z.string().optional(),- // DuckLake "Custom parameters" fields+ // DuckLake connection fieldsducklakeCatalogUrl: z.string().optional(),ducklakeDataPath: z.string().optional(),ducklakePoolSize: zdiff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.utils.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.utils.tsindex 1d8c9b43c41..fe3deeb082d 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.utils.ts+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/DuckLake.utils.ts@@ -14,7 +14,7 @@ export type DucklakeApiConfig = {metadata_schema?: string}-// Fields entered when configuring DuckLake manually (always present in the validation data).+// Fields entered when connecting to an existing DuckLake catalog and storage.const DUCKLAKE_INPUT_FIELD_PATHS = ['ducklakeCatalogUrl','ducklakeDataPath',@@ -25,12 +25,8 @@ const DUCKLAKE_INPUT_FIELD_PATHS = ['ducklakeMetadataSchema',] as const-// Fields entered only in "Use Supabase" mode (optional in the validation data).-const DUCKLAKE_SUPABASE_FIELD_PATHS = [- 'ducklakeCatalogProjectRef',- 'ducklakeStorageProjectRef',- 'ducklakeStorageBucket',-] as const+// Fields entered only in managed mode.+const DUCKLAKE_SUPABASE_FIELD_PATHS = ['ducklakeStorageBucket'] as consttype DucklakeFieldPath =| (typeof DUCKLAKE_INPUT_FIELD_PATHS)[number]@@ -52,11 +48,9 @@ type DucklakeValidationData = Pick<>>-// Required fields per mode. "Use Supabase" only needs project refs + a bucket; the catalog URL and-// S3 credentials are resolved by the platform API.+// Managed mode only needs a bucket. The platform API resolves the current project's catalog and+// storage credentials.const DUCKLAKE_SUPABASE_REQUIRED_FIELDS: DucklakeValidationIssue[] = [- { path: 'ducklakeCatalogProjectRef', message: 'Catalog project is required.' },- { path: 'ducklakeStorageProjectRef', message: 'Storage project is required.' },{ path: 'ducklakeStorageBucket', message: 'Bucket is required.' },]diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/Fields.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/Fields.tsxindex 7fedb790004..7a04498b571 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/Fields.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/DuckLake/Fields.tsx@@ -1,3 +1,4 @@+import { useParams } from 'common'import { Check, Eye, EyeOff, Plus } from 'lucide-react'import { useMemo, useState } from 'react'import { useWatch, type UseFormReturn } from 'react-hook-form'@@ -32,11 +33,9 @@ import {ScrollArea,Select,SelectContent,- SelectGroup,SelectItem,SelectTrigger,} from 'ui'-import { Admonition } from 'ui-patterns/Admonition'import { Input as PasswordInput } from 'ui-patterns/DataInputs/Input'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { SelectionListState } from 'ui-patterns/SelectionListState'@@ -45,10 +44,8 @@ import { STORED_SECRET_PLACEHOLDER } from '../DestinationForm.constants'import type { DestinationPanelSchemaType } from '../DestinationForm.schema'import {DUCKLAKE_BUCKET_FIELD_COPY,- DUCKLAKE_CATALOG_PROJECT_FIELD_COPY,DUCKLAKE_CATALOG_URL_FIELD_COPY,DUCKLAKE_DATA_PATH_FIELD_COPY,- DUCKLAKE_STORAGE_PROJECT_FIELD_COPY,} from '../DestinationFormFieldCopy'import {isMetadataListErrorVisible,@@ -60,25 +57,20 @@ import {DUCKLAKE_MODE_SUPABASE,type DucklakeMode,} from './DuckLake.constants'-import { useOrgProjectsInfiniteQuery } from '@/data/projects/org-projects-infinite-query'import { useBucketCreateMutation } from '@/data/storage/bucket-create-mutation'import { usePaginatedBucketsQuery } from '@/data/storage/buckets-query'-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'-import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-import { PROJECT_STATUS } from '@/lib/constants'const DUCKLAKE_MODE_OPTIONS = [{value: DUCKLAKE_MODE_SUPABASE,- label: 'Select Supabase projects',+ label: 'Use this Supabase project',description:- 'Choose projects for the Postgres catalog and Storage bucket. They can be the same project; Pipelines creates credentials.',+ 'Uses this project’s Postgres database and Storage. Pipelines creates the required credentials.',},{value: DUCKLAKE_MODE_CUSTOM,label: 'Enter connection details',- description:- 'Provide a Postgres catalog URL and S3-compatible storage details and credentials.',+ description: 'Provide a Postgres catalog URL and S3-compatible storage credentials.',},] as const@@ -108,116 +100,43 @@ const DuckLakeModeSelector = ({}const DuckLakeSupabaseFields = ({ form }: { form: UseFormReturn<DestinationPanelSchemaType> }) => {- const ducklakeStorageProjectRef = useWatch({- control: form.control,- name: 'ducklakeStorageProjectRef',- })+ const { ref: projectRef } = useParams()const [showNewBucketDialog, setShowNewBucketDialog] = useState(false)const [newBucketName, setNewBucketName] = useState('')- const { data: organization } = useSelectedOrganizationQuery()- const { data: sourceProject } = useSelectedProjectQuery()- const sourceRegion = sourceProject?.region-- const { data: projectsData } = useOrgProjectsInfiniteQuery(- { slug: organization?.slug, statuses: [PROJECT_STATUS.ACTIVE_HEALTHY] },- { enabled: !!organization?.slug }- )-- const projects = useMemo(- () =>- (projectsData?.pages.flatMap((page) => page.projects) ?? []).filter(- (project) => !project.is_branch- ),- [projectsData]- )- const projectsByRef = useMemo(- () => new Map(projects.map((project) => [project.ref, project])),- [projects]- )- const storageProjectName =- projectsByRef.get(ducklakeStorageProjectRef ?? '')?.name ??- (ducklakeStorageProjectRef === sourceProject?.ref- ? sourceProject?.name- : ducklakeStorageProjectRef)-- const regionForRef = (ref?: string) => {- if (!ref) return undefined- const region = projectsByRef.get(ref)?.region- if (region) return region- return ref === sourceProject?.ref ? sourceProject?.region : undefined- }-const { mutate: createBucket, isPending: isCreatingBucket } = useBucketCreateMutation({onSuccess: (_, vars) => {- form.setValue('ducklakeStorageBucket', vars.id)+ form.setValue('ducklakeStorageBucket', vars.id, { shouldDirty: true, shouldValidate: true })setNewBucketName('')setShowNewBucketDialog(false)},})- const handleCreateBucket = async () => {+ const handleCreateBucket = () => {const name = newBucketName.trim()- if (!name || !ducklakeStorageProjectRef) return+ if (!name || !projectRef) returnif (name.includes('/')) {return toast.error('Bucket name cannot contain "/".')}createBucket({- projectRef: ducklakeStorageProjectRef,+ projectRef,id: name,type: 'STANDARD',isPublic: false,})}- const renderRegionWarning = (ref?: string) => {- const region = regionForRef(ref)- if (!region || !sourceRegion || region === sourceRegion) return null- return (- <Admonition- type="warning"- className="mb-0"- description={`This project is in ${region}, a different region than your source project (${sourceRegion}). Cross-region replication can add noticeable latency.`}- />- )- }-return (<div className="flex flex-col gap-y-6"><div className="flex flex-col gap-y-1"><p className="text-sm font-medium text-foreground">Catalog</p><p className="text-sm text-foreground-light">- DuckLake metadata is stored in the selected project’s Postgres database.+ DuckLake metadata is stored in this project’s Postgres database.</p></div>- <FormField- control={form.control}- name="ducklakeCatalogProjectRef"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label={DUCKLAKE_CATALOG_PROJECT_FIELD_COPY.label}- description={- <div className="flex flex-col gap-y-2">- {renderRegionWarning(field.value)}- <span>{DUCKLAKE_CATALOG_PROJECT_FIELD_COPY.description}</span>- </div>- }- >- <FormControl>- <ProjectSelection- value={field.value}- onChange={field.onChange}- placeholder="Select a project"- />- </FormControl>- </FormItemLayout>- )}- />-<FormFieldcontrol={form.control}name="ducklakeMetadataSchema"@@ -237,39 +156,10 @@ const DuckLakeSupabaseFields = ({ form }: { form: UseFormReturn<DestinationPanel<div className="flex flex-col gap-y-1"><p className="text-sm font-medium text-foreground">Object storage</p><p className="text-sm text-foreground-light">- Replicated data files are written to a Storage bucket in the selected project.+ Replicated data files are written to a Storage bucket in this project.</p></div>- <FormField- control={form.control}- name="ducklakeStorageProjectRef"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label={DUCKLAKE_STORAGE_PROJECT_FIELD_COPY.label}- description={- <div className="flex flex-col gap-y-2">- {renderRegionWarning(field.value)}- <span>{DUCKLAKE_STORAGE_PROJECT_FIELD_COPY.description}</span>- </div>- }- >- <FormControl>- <ProjectSelection- value={field.value}- onChange={(value) => {- field.onChange(value)- // Buckets are project-scoped, so clear the selection when the project changes- form.setValue('ducklakeStorageBucket', '')- }}- placeholder="Select a project"- />- </FormControl>- </FormItemLayout>- )}- />-<FormFieldcontrol={form.control}name="ducklakeStorageBucket"@@ -281,7 +171,6 @@ const DuckLakeSupabaseFields = ({ form }: { form: UseFormReturn<DestinationPanel><FormControl><BucketSelection- form={form}value={field.value}onChange={field.onChange}onCreateBucket={() => setShowNewBucketDialog(true)}@@ -295,9 +184,7 @@ const DuckLakeSupabaseFields = ({ form }: { form: UseFormReturn<DestinationPanel<DialogContent size="small"><DialogHeader><DialogTitle>New bucket</DialogTitle>- <DialogDescription>- Creates a private bucket in the selected Storage project ({storageProjectName}).- </DialogDescription>+ <DialogDescription>Creates a private bucket in this project.</DialogDescription></DialogHeader><DialogSectionSeparator /><DialogSection className="flex flex-col gap-y-2">@@ -635,9 +522,9 @@ export const DuckLakeFields = ({}) => {const ducklakeMode = (useWatch({ control: form.control, name: 'ducklakeMode' }) ??DUCKLAKE_MODE_SUPABASE) as DucklakeMode- // The platform API resolves "Use Supabase" config into a flat catalog URL + provisioned S3+ // The platform API resolves the managed config into a flat catalog URL + provisioned S3// credentials before persisting, so an existing destination can only be edited as custom- // parameters — the original project selections aren't recoverable.+ // parameters.const effectiveMode = editMode ? DUCKLAKE_MODE_CUSTOM : ducklakeModereturn (@@ -666,104 +553,18 @@ export const DuckLakeFields = ({)}-const ProjectSelection = ({- value,- onChange,- placeholder,-}: {- value: string | undefined- onChange: (value: string) => void- placeholder: string-}) => {- const { data: organization } = useSelectedOrganizationQuery()-- const {- data: projectsData,- isPending: isPendingProjects,- isFetching: isFetchingProjects,- isError: isErrorProjects,- refetch: refetchProjects,- } = useOrgProjectsInfiniteQuery(- { slug: organization?.slug, statuses: [PROJECT_STATUS.ACTIVE_HEALTHY] },- { enabled: !!organization?.slug }- )-- const projects = useMemo(- () =>- (projectsData?.pages.flatMap((page) => page.projects) ?? []).filter(- (project) => !project.is_branch- ),- [projectsData]- )- const isProjectsErrorVisible = isMetadataListErrorVisible(isErrorProjects, projects.length)-- const projectsByRef = useMemo(- () => new Map(projects.map((project) => [project.ref, project])),- [projects]- )-- const projectLabel = (ref?: string) => {- if (!ref) return undefined- const project = projectsByRef.get(ref)- return project ? `${project.name} · ${project.ref}` : ref- }- const { handleOpenChange: handleRefreshProjectsOnOpen } = useRefreshOnOpen({- isEnabled: !!organization?.slug,- refetch: refetchProjects,- })-- return (- <Select value={value || ''} onValueChange={onChange} onOpenChange={handleRefreshProjectsOnOpen}>- <SelectTrigger>{projectLabel(value) ?? placeholder}</SelectTrigger>- <SelectContent>- <SelectGroup>- <SelectionListState- isLoading={isMetadataListLoading(- isPendingProjects || isFetchingProjects,- projects.length- )}- isError={isProjectsErrorVisible}- isEmpty={- !isMetadataListLoading(isPendingProjects || isFetchingProjects, projects.length) &&- !isProjectsErrorVisible &&- projects.length === 0- }- emptyLabel="No active projects available"- errorLabel="Unable to load projects"- />- {projects.map((project) => (- <SelectItem key={project.ref} value={project.ref}>- <div className="flex flex-col">- <span>{project.name}</span>- <span className="text-foreground-lighter">- {project.ref} · {project.region}- </span>- </div>- </SelectItem>- ))}- </SelectGroup>- </SelectContent>- </Select>- )-}-const BucketSelection = ({- form,value,onChange,onCreateBucket,}: {- form: UseFormReturn<DestinationPanelSchemaType>value: string | undefinedonChange: (value: string) => voidonCreateBucket: () => void}) => {const [searchTerm, setSearchTerm] = useState('')const [isDropdownOpen, setIsDropdownOpen] = useState(false)- const ducklakeStorageProjectRef = useWatch({- control: form.control,- name: 'ducklakeStorageProjectRef',- })+ const { ref: projectRef } = useParams()const {data: bucketsData,@@ -771,10 +572,7 @@ const BucketSelection = ({isFetching: isFetchingBuckets,isError: isErrorBuckets,refetch: refetchBuckets,- } = usePaginatedBucketsQuery(- { projectRef: ducklakeStorageProjectRef },- { enabled: !!ducklakeStorageProjectRef }- )+ } = usePaginatedBucketsQuery({ projectRef }, { enabled: !!projectRef })const buckets = useMemo(() =>@@ -789,18 +587,10 @@ const BucketSelection = ({buckets.length)const { handleOpenChange: handleRefreshBucketsOnOpen } = useRefreshOnOpen({- isEnabled: !!ducklakeStorageProjectRef,+ isEnabled: !!projectRef,refetch: refetchBuckets,})- if (!ducklakeStorageProjectRef) {- return (- <ComboboxTrigger size="small" disabled>- Select a storage project first- </ComboboxTrigger>- )- }-return (<Popovermodal={false}diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsxindex 59a22fac1d3..bcfe356fe8f 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx@@ -179,10 +179,9 @@ export const DestinationForm = ({pipelineData,catalogToken,region: projectSettings?.region,- projectRef,editMode,}),- [destinationData, pipelineData, catalogToken, projectSettings, projectRef, editMode]+ [destinationData, pipelineData, catalogToken, projectSettings, editMode])const form = useForm<z.infer<typeof FormSchema>>({mode: 'onSubmit',