Files
lincodex/backend/db/migrations/00054_add_practice_job_runner_run.sql
T

21 lines
1017 B
SQL

-- +goose Up
-- A finished practice job keeps the opaque run ID under which the code runner
-- held the run that produced the stored result. The ID is the HMAC-derived
-- value of the run key (attempt item, submission, generation) that the runner
-- itself logs, so an operator can match a stored result to one runner run
-- without the runner learning who the candidate is. Only the finishing try
-- writes it, in the transaction that stores the result; a failed or unfinished
-- job has none. The ID is unique, because one run produces at most one result.
ALTER TABLE assessment_practice_jobs
ADD COLUMN runner_run_id uuid,
ADD CONSTRAINT assessment_practice_jobs_runner_run_state CHECK (
runner_run_id IS NULL OR state = 'finished'
),
ADD CONSTRAINT assessment_practice_jobs_runner_run_key UNIQUE (runner_run_id);
-- +goose Down
ALTER TABLE assessment_practice_jobs
DROP CONSTRAINT assessment_practice_jobs_runner_run_key,
DROP CONSTRAINT assessment_practice_jobs_runner_run_state,
DROP COLUMN runner_run_id;