hydra/src/sql/upgrade-73.sql
Graham Christensen f1e75c8bff
Move evaluation errors from evaluations to EvaluationErrors, a new table
DBIx likes to eagerly select all columns without a way to really tell
it so. Therefore, this splits this one large column in to its own
table.

I'd also like to make "jobsets" use this table too, but that is on hold
to stop the bleeding caused by the extreme amount of traffic this is
causing.
2021-02-01 21:33:14 -05:00

35 lines
1 KiB
SQL

create table EvaluationErrors (
id serial primary key not null,
errorMsg text, -- error output from the evaluator
errorTime integer, -- timestamp associated with errorMsg
jobsetEvalId integer not null,
FOREIGN KEY (jobsetEvalId)
REFERENCES JobsetEvals(id)
ON DELETE SET NULL
);
ALTER TABLE JobsetEvals
ADD COLUMN evaluationerror_id integer NULL,
ADD FOREIGN KEY (evaluationerror_id)
REFERENCES EvaluationErrors(id)
ON DELETE SET NULL;
INSERT INTO EvaluationErrors
(errorMsg, errorTime, jobsetEvalId)
SELECT errorMsg, errorTime, id
FROM JobsetEvals
WHERE JobsetEvals.errorMsg != '' and JobsetEvals.errorMsg is not null;
UPDATE JobsetEvals
SET evaluationerror_id = EvaluationErrors.id
FROM EvaluationErrors
WHERE JobsetEvals.id = EvaluationErrors.jobsetEvalId
AND JobsetEvals.errorMsg != '' and JobsetEvals.errorMsg is not null;
ALTER TABLE JobsetEvals
DROP COLUMN errorMsg,
DROP COLUMN errorTime;
ALTER TABLE EvaluationErrors
DROP COLUMN jobsetEvalId;