Files
Bookra/apps/backend/migrations/00017_notification_cursors.sql
T
Tomas DvorakandDevin 2464aa45fa feat(notifications): persistent read cursor + delivery history
notification_cursors table stores one read-cursor per user per tenant;
GET /v1/activity returns unreadCount + readAt, POST /v1/activity/read
persists the cursor. Reminder dispatches now append reminder.sent /
reminder.failed system events so delivery history reaches the feed.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 16:55:21 +02:00

16 lines
603 B
SQL

-- +goose Up
-- Persistent read state for the notification feed: one cursor per
-- dashboard user per tenant. Events with created_at <= read_at count as
-- read; everything newer is unread. Per-event flags were rejected — the
-- feed is an audit list, not a per-item inbox.
CREATE TABLE notification_cursors (
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
user_subject text NOT NULL,
read_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (tenant_id, user_subject)
);
-- +goose Down
DROP TABLE IF EXISTS notification_cursors;