From c20d7816dec36fe455c6b62616ff0062502bec3e Mon Sep 17 00:00:00 2001 From: "K.Filippopolitis" <56073635+KFilippopolitis@users.noreply.github.com> Date: Mon, 27 Sep 2021 12:08:12 +0300 Subject: [PATCH] Update V7_1__NewExperimentResultFormat.sql Cherry pick updated migration script 7.1 --- .../V7_1__NewExperimentResultFormat.sql | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql b/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql index d124f9458..e1d5f12c4 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); -- GitLab