@@ -6,31 +6,31 @@ COMMENT ON TYPE provisioner_job_status IS 'Computed status of a provisioner job.
6
6
ALTER TABLE provisioner_jobs ADD COLUMN
7
7
job_status provisioner_job_status NOT NULL GENERATED ALWAYS AS (
8
8
CASE
9
- -- Completed means it is not in an "-ing" state
10
- WHEN completed_at IS NOT NULL THEN
11
- CASE
12
- -- The order of these checks are important.
13
- -- Check the error first, then cancelled, then completed.
14
- WHEN error != ' ' THEN ' failed' ::provisioner_job_status
15
- WHEN canceled_at IS NOT NULL THEN ' canceled' ::provisioner_job_status
16
- ELSE ' succeeded' ::provisioner_job_status
17
- END
9
+ -- Completed means it is not in an "-ing" state
10
+ WHEN completed_at IS NOT NULL THEN
11
+ CASE
12
+ -- The order of these checks are important.
13
+ -- Check the error first, then cancelled, then completed.
14
+ WHEN error != ' ' THEN ' failed' ::provisioner_job_status
15
+ WHEN canceled_at IS NOT NULL THEN ' canceled' ::provisioner_job_status
16
+ ELSE ' succeeded' ::provisioner_job_status
17
+ END
18
18
-- Not completed means it is in some "-ing" state
19
- ELSE
20
- CASE
21
- -- This should never happen because all errors set
22
- -- should also set a completed_at timestamp.
23
- -- But if there is an error, we should always return
24
- -- a failed state.
25
- WHEN error != ' ' THEN ' failed' ::provisioner_job_status
26
- WHEN canceled_at IS NOT NULL THEN ' canceling' ::provisioner_job_status
27
- -- Not done and not started means it is pending
28
- WHEN started_at IS NULL THEN ' pending' ::provisioner_job_status
29
- ELSE ' running' ::provisioner_job_status
30
- END
31
- END
19
+ ELSE
20
+ CASE
21
+ -- This should never happen because all errors set
22
+ -- should also set a completed_at timestamp.
23
+ -- But if there is an error, we should always return
24
+ -- a failed state.
25
+ WHEN error != ' ' THEN ' failed' ::provisioner_job_status
26
+ WHEN canceled_at IS NOT NULL THEN ' canceling' ::provisioner_job_status
27
+ -- Not done and not started means it is pending
28
+ WHEN started_at IS NULL THEN ' pending' ::provisioner_job_status
29
+ ELSE ' running' ::provisioner_job_status
30
+ END
31
+ END
32
32
-- Stored so we do not have to recompute it every time.
33
- ) STORED;
33
+ ) STORED;
34
34
35
35
36
36
COMMENT ON COLUMN provisioner_jobs.job_status IS ' Computed column to track the status of the job.' ;
0 commit comments