From 9a2c47eeec32972456cee42e8848098c081e0f46 Mon Sep 17 00:00:00 2001 From: cka-y Date: Mon, 15 Jun 2026 15:27:15 -0400 Subject: [PATCH 1/2] feat: seed api.announcements notification type --- liquibase/changelog_user.xml | 2 ++ liquibase/changes_user/feat_1729.sql | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 liquibase/changes_user/feat_1729.sql diff --git a/liquibase/changelog_user.xml b/liquibase/changelog_user.xml index 55a569b13..e23defb24 100644 --- a/liquibase/changelog_user.xml +++ b/liquibase/changelog_user.xml @@ -15,4 +15,6 @@ + + diff --git a/liquibase/changes_user/feat_1729.sql b/liquibase/changes_user/feat_1729.sql new file mode 100644 index 000000000..4e2458549 --- /dev/null +++ b/liquibase/changes_user/feat_1729.sql @@ -0,0 +1,4 @@ +-- Seed 'api.announcements' notification type (idempotent). +INSERT INTO notification_type (id, description) +VALUES ('api.announcements', 'API announcements') +ON CONFLICT (id) DO NOTHING; From b240178df156508eb661c1fe0fe59654b8b54807 Mon Sep 17 00:00:00 2001 From: cka-y Date: Mon, 15 Jun 2026 15:30:26 -0400 Subject: [PATCH 2/2] feat: backfill subscription for existing users --- liquibase/changes_user/feat_1729.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/liquibase/changes_user/feat_1729.sql b/liquibase/changes_user/feat_1729.sql index 4e2458549..6feb381c6 100644 --- a/liquibase/changes_user/feat_1729.sql +++ b/liquibase/changes_user/feat_1729.sql @@ -2,3 +2,14 @@ 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 + WHERE s.user_id = u.id + AND s.notification_type_id = 'api.announcements' + );