Skip to content

Device token

Purpose

TBD by human

Identity & key fields

  • Primary key: id (uuid, default gen_random_uuid()).
  • userId (uuid, NOT NULL, FK → users.users.id, on-delete cascade).
  • token (text, NOT NULL).
  • platform (enum device_platform: IOS, ANDROID, WEB).
  • createdAt, updatedAt (timestamps, NOT NULL).

business meaning: TBD by human

Invariants

  • UNIQUE on (userId, token) — same token cannot be registered twice for the same user (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/notifications.schema.ts).
  • userId ON DELETE CASCADE — tokens vanish with the user (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/notifications.schema.ts).
  • userId, token, platform NOT NULL (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/notifications.schema.ts).

business invariants: TBD by human

Lifecycle

No explicit status column — rows are added on registration and removed on de-registration or cascade.

Relationships

  • User (ENT-021) — userIdusers.users.id, on-delete cascade. N:1.

API surfaces

SurfaceExposedNotes
clientinferred yes — registered via libs/features/notifications/src/lib/notifications-client.module.ts; no dedicated DTO appears in audit-time client OpenAPI extractSwagger UI
businessno
super-adminno

Known gotchas / open questions

  • Same token value may be registered for different userIds (UNIQUE is per-user, not global) — confirm whether device hand-off between accounts requires explicit cleanup.
  • OPEN: is there token expiry / invalidation handling, or does the FCM dispatcher prune on send failure? Not visible in schema.