| 1 | -- SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | |
| 3 | -- name: InsertWorkflowStep :one |
| 4 | INSERT INTO workflow_steps ( |
| 5 | job_id, step_index, step_id, step_name, if_expr, |
| 6 | run_command, uses_alias, working_directory, step_env, continue_on_error, |
| 7 | step_with |
| 8 | ) VALUES ( |
| 9 | $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11 |
| 10 | ) |
| 11 | RETURNING id, job_id, step_index, step_id, step_name, if_expr, |
| 12 | run_command, uses_alias, working_directory, step_env, |
| 13 | continue_on_error, status, conclusion, log_object_key, |
| 14 | log_byte_count, started_at, completed_at, version, |
| 15 | created_at, updated_at, step_with; |
| 16 | |
| 17 | -- name: GetWorkflowStepByID :one |
| 18 | SELECT id, job_id, step_index, step_id, step_name, if_expr, |
| 19 | run_command, uses_alias, working_directory, step_env, |
| 20 | continue_on_error, status, conclusion, log_object_key, |
| 21 | log_byte_count, started_at, completed_at, version, |
| 22 | created_at, updated_at, step_with |
| 23 | FROM workflow_steps |
| 24 | WHERE id = $1; |
| 25 | |
| 26 | -- name: UpdateWorkflowStepStatus :one |
| 27 | UPDATE workflow_steps |
| 28 | SET status = $2, |
| 29 | conclusion = sqlc.narg(conclusion)::check_conclusion, |
| 30 | started_at = sqlc.narg(started_at)::timestamptz, |
| 31 | completed_at = sqlc.narg(completed_at)::timestamptz, |
| 32 | version = version + 1, |
| 33 | updated_at = now() |
| 34 | WHERE id = $1 |
| 35 | RETURNING id, job_id, step_index, step_id, step_name, if_expr, |
| 36 | run_command, uses_alias, working_directory, step_env, |
| 37 | continue_on_error, status, conclusion, log_object_key, |
| 38 | log_byte_count, started_at, completed_at, version, |
| 39 | created_at, updated_at, step_with; |
| 40 | |
| 41 | -- name: CancelOpenWorkflowStepsForJob :many |
| 42 | UPDATE workflow_steps |
| 43 | SET status = 'cancelled', |
| 44 | conclusion = 'cancelled', |
| 45 | started_at = COALESCE(started_at, now()), |
| 46 | completed_at = COALESCE(completed_at, now()), |
| 47 | version = version + 1, |
| 48 | updated_at = now() |
| 49 | WHERE job_id = $1 |
| 50 | AND status IN ('queued', 'running') |
| 51 | RETURNING id, job_id, step_index, step_id, step_name, if_expr, |
| 52 | run_command, uses_alias, working_directory, step_env, |
| 53 | continue_on_error, status, conclusion, log_object_key, |
| 54 | log_byte_count, started_at, completed_at, version, |
| 55 | created_at, updated_at, step_with; |
| 56 | |
| 57 | -- name: UpdateWorkflowStepLogObject :one |
| 58 | UPDATE workflow_steps |
| 59 | SET log_object_key = sqlc.narg(log_object_key)::text, |
| 60 | log_byte_count = sqlc.arg(log_byte_count)::bigint, |
| 61 | version = version + 1, |
| 62 | updated_at = now() |
| 63 | WHERE id = sqlc.arg(id)::bigint |
| 64 | RETURNING id, job_id, step_index, step_id, step_name, if_expr, |
| 65 | run_command, uses_alias, working_directory, step_env, |
| 66 | continue_on_error, status, conclusion, log_object_key, |
| 67 | log_byte_count, started_at, completed_at, version, |
| 68 | created_at, updated_at, step_with; |
| 69 | |
| 70 | -- name: ListRunnerStepsForJob :many |
| 71 | SELECT id, job_id, step_index, step_id, step_name, if_expr, |
| 72 | run_command, uses_alias, working_directory, step_env, |
| 73 | continue_on_error, status, conclusion, log_byte_count, |
| 74 | started_at, completed_at, created_at, step_with |
| 75 | FROM workflow_steps |
| 76 | WHERE job_id = $1 |
| 77 | ORDER BY step_index ASC; |
| 78 | |
| 79 | -- name: GetFirstStepForJob :one |
| 80 | SELECT id, job_id, step_index, step_id, step_name, if_expr, |
| 81 | run_command, uses_alias, working_directory, step_env, |
| 82 | continue_on_error, status, conclusion, log_object_key, |
| 83 | log_byte_count, started_at, completed_at, version, |
| 84 | created_at, updated_at, step_with |
| 85 | FROM workflow_steps |
| 86 | WHERE job_id = $1 |
| 87 | ORDER BY step_index ASC |
| 88 | LIMIT 1; |
| 89 | |
| 90 | -- name: ListStepsForJob :many |
| 91 | SELECT id, job_id, step_index, step_id, step_name, run_command, |
| 92 | uses_alias, status, conclusion, log_object_key, log_byte_count, |
| 93 | started_at, completed_at, created_at, updated_at |
| 94 | FROM workflow_steps |
| 95 | WHERE job_id = $1 |
| 96 | ORDER BY step_index ASC; |
| 97 |