UserTokens table

The UserTokens table in the FitStack - V2 schema has 19 columns, keyed by Id, with 1 foreign key to Users. 1 column in TokenEvents references it.

AggregateRoot, not Auditable — `LastModifiedAt`, and no soft delete. Rows are only ever status-flipped to Revoked, never deleted, and no cleanup job exists — the table grows without bound per user. Never eager-load this collection off Users.

Columns (19)

Columns of the UserTokens table
ColumnTypeConstraintsDescription
Iduuidprimary key, not nullValueGeneratedNever — assigned by the domain.
UserIdcharacter varying(450)not null, references Users.IdDelete behavior RESTRICT — a user with live tokens cannot be hard-deleted.
JwtIdcharacter varying(128)not null
Statuscharacter varying(50)not null`TokenStatus` as TEXT.
RevokedAttimestamp with time zone
RevokedReasoncharacter varying(500)
LastUsedAttimestamp with time zone
UseCountintegernot null
TokenValuecharacter varying(2048)not nullOwned Token VO.
TokenTypecharacter varying(50)not nullOwned Token VO.
TokenIssuedAttimestamp with time zonenot nullOwned Token VO.
TokenExpiresAttimestamp with time zonenot nullOwned Token VO.
MetadataIpAddresscharacter varying(45)Owned TokenMetadata VO.
MetadataUserAgentcharacter varying(512)Owned TokenMetadata VO.
MetadataDeviceIdcharacter varying(128)Owned TokenMetadata VO.
MetadataCustomClaimscharacter varying(4000)Owned TokenMetadata VO, JSON.
Versionintegernot null
CreatedAttimestamp with time zonenot null
LastModifiedAttimestamp with time zone

Indexes (4)

  • (TokenValue) unique (IX_UserTokens_TokenValue)
  • (UserId) (IX_UserTokens_UserId)
  • (JwtId) (IX_UserTokens_JwtId)
  • (UserId, Status) (IX_UserTokens_UserId_Status)

Relationships