Pass entitlement template
Purpose
TBD by human
Identity & key fields
- Primary key:
id(uuid, defaultgen_random_uuid()). passId(uuid, NOT NULL, FK →passes.pass.id, on-delete restrict).activityId(uuid, NOT NULL, FK →activities.activities.id, on-delete restrict).sessionsLimit(nullable integer) — NULL = unlimited.isActive(boolean, NOT NULL, defaulttrue).
business meaning: TBD by human
Invariants
passId,activityIdNOT NULL with ON DELETE RESTRICT (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/passes.schema.ts).isActivedefaults totrue;isActiveNOT NULL (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/passes.schema.ts).
business invariants: TBD by human
Lifecycle
No status column; soft-deactivated via isActive=false.
Relationships
- Pass (ENT-029) —
passId→passes.pass.id, on-delete restrict. N:1. - Activity (ENT-005) —
activityId→activities.activities.id, on-delete restrict. N:1. - Pass entitlement covered extra (ENT-030) — 1:N.
- Customer entitlement (ENT-027) — snapshotted from this template at purchase time (no FK in
customer_entitlementto here).
API surfaces
| Surface | Exposed | Notes |
|---|---|---|
| client | no — included indirectly inside PassClientDto and MyEntitlementDto shapes | — |
| business | yes — PassEntitlementTemplateResponseDto, CreatePassEntitlementDto, UpdatePassEntitlementDto | Swagger UI |
| super-admin | no | — |
Known gotchas / open questions
- Application-level invariant: one entitlement-template per
(passId, activityId)— a pass may include each activity at most once. No DB constraint enforces this today (no UNIQUE on the pair). The service layer must validate before insert. OPEN: addUNIQUE (pass_id, activity_id)in a future migration to make the invariant DB-enforced. - ON DELETE RESTRICT on both FKs — a pass with active entitlements cannot be deleted, and an activity referenced by any entitlement cannot be deleted.