Skip to content

Commit

Permalink
Fix migration for drafts without recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
terolaakso committed Feb 7, 2025
1 parent 62072ec commit 6472523
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
ALTER TABLE message_draft
ADD COLUMN recipients jsonb DEFAULT '[]'::jsonb;
ADD COLUMN recipients jsonb DEFAULT '[]'::jsonb NOT NULL;

UPDATE message_draft
SET recipients = (SELECT jsonb_agg(jsonb_build_object('accountId', id, 'starter', false))
FROM (SELECT unnest(recipient_ids) AS id));
SET recipients = COALESCE(
(SELECT jsonb_agg(jsonb_build_object('accountId', id, 'starter', false))
FROM (SELECT unnest(recipient_ids) AS id))
, '[]'::jsonb);

ALTER TABLE message_draft
DROP COLUMN recipient_ids;

0 comments on commit 6472523

Please sign in to comment.