From d91a10ef8ef7cf4a8bdcc2e43a7a170614ee42c4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 27 Mar 2026 19:55:40 +0100 Subject: [PATCH] feat(backend): add V16 migration for notifications table and user preference columns Co-Authored-By: Claude Sonnet 4.6 --- .../V16__notifications_and_preferences.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V16__notifications_and_preferences.sql diff --git a/backend/src/main/resources/db/migration/V16__notifications_and_preferences.sql b/backend/src/main/resources/db/migration/V16__notifications_and_preferences.sql new file mode 100644 index 00000000..bc3bcc2d --- /dev/null +++ b/backend/src/main/resources/db/migration/V16__notifications_and_preferences.sql @@ -0,0 +1,16 @@ +-- Notification preferences on the user record — no separate entity needed +ALTER TABLE users ADD COLUMN notify_on_reply BOOLEAN NOT NULL DEFAULT false; +ALTER TABLE users ADD COLUMN notify_on_mention BOOLEAN NOT NULL DEFAULT false; + +-- In-app notifications +CREATE TABLE notifications ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + recipient_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, + type VARCHAR(32) NOT NULL, -- 'REPLY' | 'MENTION' + document_id UUID, + reference_id UUID, -- commentId that triggered this notification + read BOOLEAN NOT NULL DEFAULT false, + created_at TIMESTAMP NOT NULL DEFAULT now() +); + +CREATE INDEX idx_notifications_recipient ON notifications(recipient_id, read, created_at DESC);