fixing Flock rename
This commit is contained in:
@@ -196,19 +196,28 @@ export const updateWorkspace = async ({
|
|||||||
billingPlan: BillingPlan;
|
billingPlan: BillingPlan;
|
||||||
}) => {
|
}) => {
|
||||||
const result = await db.query<WorkspaceRow>(
|
const result = await db.query<WorkspaceRow>(
|
||||||
`UPDATE workspaces
|
`WITH input AS (
|
||||||
SET name = $2,
|
SELECT
|
||||||
workspace_type = $3::varchar,
|
$1::integer AS workspace_id,
|
||||||
billing_email = $4,
|
$2::varchar AS name,
|
||||||
billing_plan = $5::varchar,
|
$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
|
rescue_verification_status = CASE
|
||||||
WHEN $3::varchar = 'rescue' AND rescue_verification_status = 'not_required' THEN 'pending'
|
WHEN input.workspace_type = 'rescue' AND workspaces.rescue_verification_status = 'not_required' THEN 'pending'
|
||||||
WHEN $3::varchar = 'standard' THEN 'not_required'
|
WHEN input.workspace_type = 'standard' THEN 'not_required'
|
||||||
ELSE rescue_verification_status
|
ELSE workspaces.rescue_verification_status
|
||||||
END,
|
END,
|
||||||
updated_at = CURRENT_TIMESTAMP
|
updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = $1
|
FROM input
|
||||||
RETURNING id, name, workspace_type, billing_email, billing_plan, subscription_status, rescue_verification_status, created_at, updated_at`,
|
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],
|
[workspaceId, name, workspaceType, billingEmail, billingPlan],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user