From 368ede5619396711cb9bb08fd7ca3bca09d8d123 Mon Sep 17 00:00:00 2001 From: blaisadmin Date: Wed, 15 Apr 2026 22:29:07 -0400 Subject: [PATCH] fixing Flock rename --- .../src/repositories/workspaceRepository.ts | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/backend/src/repositories/workspaceRepository.ts b/backend/src/repositories/workspaceRepository.ts index c140bdc..c576e5a 100644 --- a/backend/src/repositories/workspaceRepository.ts +++ b/backend/src/repositories/workspaceRepository.ts @@ -196,19 +196,28 @@ export const updateWorkspace = async ({ billingPlan: BillingPlan; }) => { const result = await db.query( - `UPDATE workspaces - SET name = $2, - workspace_type = $3::varchar, - billing_email = $4, - billing_plan = $5::varchar, + `WITH input AS ( + SELECT + $1::integer AS workspace_id, + $2::varchar AS name, + $3::varchar AS workspace_type, + $4::varchar AS billing_email, + $5::varchar AS billing_plan + ) + UPDATE workspaces + SET name = input.name, + workspace_type = input.workspace_type, + billing_email = input.billing_email, + billing_plan = input.billing_plan, rescue_verification_status = CASE - WHEN $3::varchar = 'rescue' AND rescue_verification_status = 'not_required' THEN 'pending' - WHEN $3::varchar = 'standard' THEN 'not_required' - ELSE rescue_verification_status + WHEN input.workspace_type = 'rescue' AND workspaces.rescue_verification_status = 'not_required' THEN 'pending' + WHEN input.workspace_type = 'standard' THEN 'not_required' + ELSE workspaces.rescue_verification_status END, updated_at = CURRENT_TIMESTAMP - WHERE id = $1 - RETURNING id, name, workspace_type, billing_email, billing_plan, subscription_status, rescue_verification_status, created_at, updated_at`, + FROM input + WHERE workspaces.id = input.workspace_id + RETURNING workspaces.id, workspaces.name, workspaces.workspace_type, workspaces.billing_email, workspaces.billing_plan, workspaces.subscription_status, workspaces.rescue_verification_status, workspaces.created_at, workspaces.updated_at`, [workspaceId, name, workspaceType, billingEmail, billingPlan], );