golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/relui/migrations/20220621201140_add_approved_at_to_tasks.down.sql (about) 1 -- Copyright 2022 The Go Authors. All rights reserved. 2 -- Use of this source code is governed by a BSD-style 3 -- license that can be found in the LICENSE file. 4 5 BEGIN; 6 7 WITH approved_task_logs AS ( 8 SELECT DISTINCT workflow_id, task_name 9 FROM task_logs 10 WHERE body = 'USER-APPROVED' 11 ) 12 13 INSERT 14 INTO task_logs (workflow_id, task_name, body, created_at, updated_at) 15 SELECT tasks.workflow_id, tasks.name, 'USER-APPROVED', tasks.approved_at, tasks.approved_at 16 FROM tasks 17 WHERE tasks.approved_at IS NOT NULL 18 AND NOT EXISTS( 19 SELECT DISTINCT 1 20 FROM approved_task_logs atl 21 WHERE atl.workflow_id = tasks.workflow_id 22 AND atl.task_name = tasks.name 23 ) 24 ; 25 26 ALTER TABLE tasks 27 DROP COLUMN approved_at; 28 29 COMMIT;