CoachAccessRequests table

The CoachAccessRequests table in the FitStack - V2 schema has 16 columns, keyed by Id, with 5 foreign keys to CoachClients, Coaches, Users and CoachAccessGrants. 2 columns in CoachAccessRequestScopes and CoachAccessGrants reference it.

The ask. Immutable once answered — a coach who wants more scopes files a new request rather than editing an approved one, so the record of what the client actually consented to cannot be rewritten after the fact. Enforce one pending request per relationship with a partial unique index: CREATE UNIQUE INDEX "IX_CoachAccessRequests_OnePending" ON "CoachAccessRequests" ("CoachClientId") WHERE "Status" = 'Pending' AND "IsDeleted" = false;

Columns (16)

Columns of the CoachAccessRequests table
ColumnTypeConstraintsDescription
Iduuidprimary key, not null
CoachClientIduuidnot null, references CoachClients.IdRESTRICT. A request only exists inside a relationship.
CoachIduuidnot null, references Coaches.IdDenormalised from CoachClients so the coach-side list query needs no join.
ClientIdtextnot null, references Users.IdDenormalised, same reason.
Statustextnot null`AccessRequestStatus`.
Reasoncharacter varying(2000)not nullRequired. The coach must say WHY, and the client sees this verbatim on the consent screen.
RequestedDurationDaysintegerNull = open-ended. The client may shorten it when approving.
ExpiresAttimestamp with time zonenot nullWhen the REQUEST goes stale — not the grant.
RespondedAttimestamp with time zone
RespondedByUserIdtextreferences Users.IdNormally the client. Recorded explicitly for support-assisted decisions.
DecisionNotecharacter varying(2000)
ResultingGrantIduuidreferences CoachAccessGrants.IdSet on approval or partial approval.
CreatedAttimestamp with time zonenot null
ModifiedAttimestamp with time zone
IsDeletedbooleannot null
DeletedAttimestamp with time zone

Indexes (3)

  • (ClientId, Status) (IX_CoachAccessRequests_ClientId_Status)
  • (CoachId, Status) (IX_CoachAccessRequests_CoachId_Status)
  • (ExpiresAt) (IX_CoachAccessRequests_ExpiresAt)

Relationships