| Version 4 (modified by , 3 hours ago) ( diff ) |
|---|
Clone an existing build
Actors
User, Admin
Scenario
- The user opens the completed builds page, opens the details popup for a build
- The user clicks on the "CLONE & EDIT" button and is redirected to the forge page
- The forge is populated with identical data as the build that was cloned
BEGIN;
WITH build_to_clone AS (
SELECT name, description, total_price
FROM build
WHERE id = $buildId
LIMIT 1
),
new_build AS (
INSERT INTO build (user_id, name, created_at, description, total_price, is_approved)
SELECT
$userId,
build_to_clone.name || ' (copy)',
CURRENT_DATE,
build_to_clone.description,
build_to_clone.total_price,
false
FROM build_to_clone
RETURNING id
),
copied_components AS (
INSERT INTO build_component (build_id, component_id)
SELECT
new_build.id,
bc.component_id
FROM new_build
JOIN build_component AS bc
ON bc.build_id = $buildId
RETURNING 1
)
COMMIT;
{{{
BEGIN;
SELECT
b.id,
b.user_id,
b.is_approved,
b.name,
b.description,
b.total_price,
FROM builds b
WHERE b.id = $1
AND b.user_id = $2
LIMIT 1;
SELECT
bc.component_id
FROM build_components bc
WHERE bc.build_id = $1;
COMMIT;
}}}
Attachments (3)
- clonedBuild.png (142.5 KB ) - added by 3 hours ago.
- clickClone.png (221.9 KB ) - added by 45 minutes ago.
- clone.png (203.5 KB ) - added by 45 minutes ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.



