CoachAccessGrantScopes table

The CoachAccessGrantScopes table in the FitStack - V2 schema has 7 columns, keyed by Id, with 2 foreign keys to CoachAccessGrants and DataScopes.

**What the coach may actually see.** The enforcement query is: SELECT gs.* FROM "CoachAccessGrantScopes" gs JOIN "CoachAccessGrants" g ON g."Id" = gs."AccessGrantId" JOIN "DataScopes" s ON s."Id" = gs."DataScopeId" WHERE g."CoachId" = @coachId AND g."ClientId" = @clientId AND g."Status" = 'Active' AND (g."ExpiresAt" IS NULL OR g."ExpiresAt" > now()) AND gs."RevokedAt" IS NULL AND s."Key" = @requiredScopeKey; No row => 403, and a `CoachDataAccessLogs` entry with the matching `DeniedX` outcome. A non-null `HistoryWindowDays` additionally clamps the date filter on the underlying query — silently, not as an error.

Columns (7)

Columns of the CoachAccessGrantScopes table
ColumnTypeConstraintsDescription
Iduuidprimary key, not null
AccessGrantIduuidnot null, references CoachAccessGrants.IdCASCADE.
DataScopeIduuidnot null, references DataScopes.IdRESTRICT.
HistoryWindowDaysintegerCoach may read records no older than now() - this. Null = all history. Must respect DataScopes.MaxHistoryWindowDays.
AllowsRealtimePushbooleannot nullGoverns the SignalR firehose that v1 ran unconditionally. Defaults to FALSE: live streaming of a client activity is opt-in, per scope.
GrantedAttimestamp with time zonenot nullPer-scope, because scopes can be added to a grant later.
RevokedAttimestamp with time zonePer-scope revocation without killing the whole grant — the client can withdraw nutrition while keeping training.

Indexes (2)

  • (AccessGrantId, DataScopeId) unique (IX_CoachAccessGrantScopes_GrantId_ScopeId)
  • (DataScopeId) (IX_CoachAccessGrantScopes_DataScopeId)

Relationships