Device token
Purpose
TBD by human
Identity & key fields
- Primary key:
id(uuid, defaultgen_random_uuid()). userId(uuid, NOT NULL, FK →users.users.id, on-delete cascade).token(text, NOT NULL).platform(enumdevice_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). userIdON DELETE CASCADE — tokens vanish with the user (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/notifications.schema.ts).userId,token,platformNOT 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) —
userId→users.users.id, on-delete cascade. N:1.
API surfaces
| Surface | Exposed | Notes |
|---|---|---|
| client | inferred yes — registered via libs/features/notifications/src/lib/notifications-client.module.ts; no dedicated DTO appears in audit-time client OpenAPI extract | Swagger UI |
| business | no | — |
| super-admin | no | — |
Known gotchas / open questions
- Same
tokenvalue may be registered for differentuserIds (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.