diff --git a/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql b/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql index d124f94583046e2ddbab071fb38ca48e1c71f03e..e1d5f12c4ce1dd9107f3a4cb1927664cfe971feb 100644 --- a/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql +++ b/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql @@ -1 +1,15 @@ -UPDATE experiment SET result = result::json #>>'{0,result}' WHERE (algorithm::json->>'type') <> 'workflow'; \ No newline at end of file +CREATE OR REPLACE FUNCTION ISJSON(p_json text) + RETURNS boolean +AS +$$ +BEGIN + RETURN (p_json::json is not null); +EXCEPTION + WHEN others THEN + RETURN false; +END; +$$ +language plpgsql +immutable; +UPDATE experiment SET result = result::json #>>'{0,result}' WHERE (algorithm::json->>'type') <> 'workflow' and ISJSON(result); +UPDATE experiment SET result = '', status = 'error' WHERE NOT ISJSON(result);