Skip to content

Commit

Permalink
feat: Add migration for analytics_logs.metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Feb 9, 2024
1 parent 56dcac3 commit 8de7402
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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');
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit 8de7402

Please sign in to comment.