Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions liquibase/changelog_user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
<include file="changes_user/feat_1684.sql" relativeToChangelogFile="true"/>
<!-- Add feature_flag and user_feature_flag tables -->
<include file="changes_user/feat_1694.sql" relativeToChangelogFile="true"/>
<!-- Seed 'api.announcements' notification type (issue #1729). -->
<include file="changes_user/feat_1729.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
15 changes: 15 additions & 0 deletions liquibase/changes_user/feat_1729.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Seed 'api.announcements' notification type (idempotent).
INSERT INTO notification_type (id, description)
VALUES ('api.announcements', 'API announcements')
ON CONFLICT (id) DO NOTHING;

-- Backfill subscriptions for users already opted in (idempotent).
INSERT INTO notification_subscription (id, user_id, notification_type_id)
SELECT gen_random_uuid()::text, u.id, 'api.announcements'
FROM app_user u
WHERE u.is_registered_to_receive_api_announcements
AND NOT EXISTS (
SELECT 1 FROM notification_subscription s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the is_registered_to_receive_api_announcements column if it's part of another issue? We will also need to modify the user migration task.

WHERE s.user_id = u.id
AND s.notification_type_id = 'api.announcements'
);
Loading