Skip to content

Pass entitlement template

Purpose

TBD by human

Identity & key fields

  • Primary key: id (uuid, default gen_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, default true).

business meaning: TBD by human

Invariants

  • passId, activityId NOT NULL with ON DELETE RESTRICT (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/passes.schema.ts).
  • isActive defaults to true; isActive NOT 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) — passIdpasses.pass.id, on-delete restrict. N:1.
  • Activity (ENT-005) — activityIdactivities.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_entitlement to here).

API surfaces

SurfaceExposedNotes
clientno — included indirectly inside PassClientDto and MyEntitlementDto shapes
businessyes — PassEntitlementTemplateResponseDto, CreatePassEntitlementDto, UpdatePassEntitlementDtoSwagger UI
super-adminno

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: add UNIQUE (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.