From e6ef4033840bcf49e741cfc49ca757ec643982fb Mon Sep 17 00:00:00 2001 From: "Anna (Anya) Parker" <50943381+anna-parker@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:09:49 +0100 Subject: [PATCH] add migration --- .../migration/V1.7__update_error_schema.sql | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V1.7__update_error_schema.sql diff --git a/backend/src/main/resources/db/migration/V1.7__update_error_schema.sql b/backend/src/main/resources/db/migration/V1.7__update_error_schema.sql new file mode 100644 index 000000000..503fab7a5 --- /dev/null +++ b/backend/src/main/resources/db/migration/V1.7__update_error_schema.sql @@ -0,0 +1,55 @@ +update sequence_entries_preprocessed_data +set warnings = ( + select json_agg( + json_build_object( + 'unprocessedFields', ( + select json_agg( + json_build_object( + 'name', source->>'name', + 'type', source->>'type' + ) + ) + from json_array_elements(warning->'source') as source + ), + 'processedFields', ( + select json_agg( + json_build_object( + 'name', source->>'name', + 'type', source->>'type' + ) + ) + from json_array_elements(warning->'source') as source + ), + 'message', warning->>'message' + ) + ) + from json_array_elements(warnings) as warning +) +where warnings is not null; +set errors = ( + select json_agg( + json_build_object( + 'unprocessedFields', ( + select json_agg( + json_build_object( + 'name', source->>'name', + 'type', source->>'type' + ) + ) + from json_array_elements(error->'source') as source + ), + 'processedFields', ( + select json_agg( + json_build_object( + 'name', source->>'name', + 'type', source->>'type' + ) + ) + from json_array_elements(error->'source') as source + ), + 'message', error->>'message' + ) + ) + from json_array_elements(errors) as error +) +where errors is not null; \ No newline at end of file