PhoenixKit.Migrations.Postgres.V104 (phoenix_kit v1.7.118)

Copy Markdown View Source

V104: Per-user notifications driven by the activity feed.

Creates phoenix_kit_notifications — one row per (activity, recipient_user) with independent seen_at / dismissed_at timestamps. Generated in fan-out fashion by PhoenixKit.Notifications.maybe_create_from_activity/1 whenever an activity targets a user other than the actor.

Schema

  • uuid — UUIDv7 primary key
  • activity_uuid — FK → phoenix_kit_activities (ON DELETE CASCADE)
  • recipient_uuid — FK → phoenix_kit_users (ON DELETE CASCADE)
  • seen_atNULL = unread; set when the user clicks the row or
                    uses "Mark all as seen"
  • dismissed_atNULL = still visible; set when the user dismisses
  • inserted_at — creation timestamp (no updated_at)

Indexes

  • Unique (activity_uuid, recipient_uuid) — one notification per activity per recipient
  • Partial (recipient_uuid, inserted_at) WHERE dismissed_at IS NULL — covers the main "my undismissed inbox, newest first" read path

All operations are idempotent.

Summary

Functions

down(opts)

up(opts)