Skip to content

Commit d028ed1

Browse files
committed
sql spacing
1 parent 7e879f9 commit d028ed1

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

coderd/database/migrations/000160_provisioner_job_status.up.sql

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ COMMENT ON TYPE provisioner_job_status IS 'Computed status of a provisioner job.
66
ALTER TABLE provisioner_jobs ADD COLUMN
77
job_status provisioner_job_status NOT NULL GENERATED ALWAYS AS (
88
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
1818
-- 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
3232
-- Stored so we do not have to recompute it every time.
33-
) STORED;
33+
) STORED;
3434

3535

3636
COMMENT ON COLUMN provisioner_jobs.job_status IS 'Computed column to track the status of the job.';

0 commit comments

Comments
 (0)