diff --git a/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/down.sql b/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/down.sql new file mode 100644 index 0000000000..f48312068d --- /dev/null +++ b/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/down.sql @@ -0,0 +1,23 @@ +UPDATE public.analytics_logs +SET metadata = jsonb_set( + metadata, + '{back,type}', + CASE + WHEN metadata->'back'->>'type' = 'Question' THEN '"Statement"' + WHEN metadata->'back'->>'type' = 'Answer' THEN '"Response"' + ELSE metadata->'back'->>'type' + END::jsonb +) +WHERE metadata->'back'->>'type' IN ('Question', 'Answer'); + +UPDATE public.analytics_logs +SET metadata = jsonb_set( + metadata, + '{change,type}', + CASE + WHEN metadata->'change'->>'type' = 'Question' THEN '"Statement"' + WHEN metadata->'change'->>'type' = 'Answer' THEN '"Response"' + ELSE metadata->'change'->>'type' + END::jsonb +) +WHERE metadata->'change'->>'type' IN ('Question', 'Answer'); diff --git a/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/up.sql b/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/up.sql new file mode 100644 index 0000000000..69b17a1efd --- /dev/null +++ b/hasura.planx.uk/migrations/1707487370419_update_metadata_component_types/up.sql @@ -0,0 +1,23 @@ +UPDATE public.analytics_logs +SET metadata = jsonb_set( + metadata, + '{back,type}', + CASE + WHEN metadata->'back'->>'type' = 'Statement' THEN '"Question"' + WHEN metadata->'back'->>'type' = 'Response' THEN '"Answer"' + ELSE metadata->'back'->>'type' + END::jsonb +) +WHERE metadata->'back'->>'type' IN ('Statement', 'Response'); + +UPDATE public.analytics_logs +SET metadata = jsonb_set( + metadata, + '{change,type}', + CASE + WHEN metadata->'change'->>'type' = 'Statement' THEN '"Question"' + WHEN metadata->'change'->>'type' = 'Response' THEN '"Answer"' + ELSE metadata->'change'->>'type' + END::jsonb +) +WHERE metadata->'change'->>'type' IN ('Statement', 'Response');