wiki:CloneBuild

Version 1 (modified by 233051, 5 hours ago) ( diff )

--

Clone an existing build

Actors

User, Admin

Scenario

  1. The user opens the completed builds page, opens the details popup for a build
  2. The user clicks on the "CLONE & EDIT" button and is redirected to the forge page
  3. The forge is populated with identical data as the build that was cloned
BEGIN;

SELECT *
FROM build
WHERE id = $buildId
LIMIT 1;

INSERT INTO build (user_id, name, created_at, description, total_price, is_approved)
SELECT
  $userId,
  (b.name || ' (copy)'),
  CURRENT_DATE,
  b.description,
  b.total_price,
  false
FROM build AS b
WHERE b.id = $buildId
RETURNING id;

SELECT component_id
FROM build_component
WHERE build_id = $buildId;

INSERT INTO build_component (build_id, component_id)
SELECT
  $newBuildId,
  bc.component_id
FROM build_component AS bc
WHERE bc.build_id = $buildId;

COMMIT;

Attachments (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.