user_devices table
The user_devices table in the Reddit Clone Database Schema schema has 8 columns, keyed by id, with 1 foreign key to users. 2 columns in user_sessions and push_subscriptions reference it.
A device outlives a session, which is why push tokens hang here and not on user_sessions. Logging out must not silently stop notifications on a device the person still owns.
Columns (8)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| user_id | uuid | not null, references users.id | |
| platform | device_platform | not null | |
| device_name | varchar(120) | ||
| push_token_hash | varchar(255) | ||
| app_version | varchar(40) | ||
| registered_at | timestamptz | not null | |
| last_seen_at | timestamptz |
Indexes (1)
(user_id, platform)
Relationships
user_devices.user_idreferencesusers.iduser_sessions.device_idreferencesuser_devicespush_subscriptions.device_idreferencesuser_devices