Appearance
user_tracks
History of accesses granted to a user through a track. Each row = one access event (purchase, import, manual assignment, …).
- ETL strategy:
merge - PK:
id
Columns
| Column | Type | Description |
|---|---|---|
id | BIGINT | PK. |
id_tenant | BIGINT | FK → tenants.id. |
id_origin | BIGINT | Resolved tracks.id_origin. |
id_track | BIGINT | FK → tracks.id. |
id_user | BIGINT | FK → users.id. |
created_at | TIMESTAMPTZ | When access was granted. |
deleted_at | TIMESTAMPTZ | When access was revoked. |
The same
(id_user, id_track)pair can appear multiple times — grants and revocations over time. For the current access state, prefermetrics.track_access_aggregates, which already consolidates activeuser_ids.
Patterns
sql
-- Active accesses for user X
SELECT t.title, ut.created_at
FROM lms.user_tracks ut
JOIN lms.tracks t ON t.id = ut.id_track AND t.id_tenant = ut.id_tenant
WHERE ut.id_user = 12345
AND ut.deleted_at IS NULL
AND t.deleted_at IS NULL
ORDER BY ut.created_at DESC;