sessions table

The sessions table in the Social Media Database Schema schema has 9 columns, keyed by id, with 1 foreign key to users.

One row per signed-in device. revoked_at null means live, which is what powers a log-out-everywhere button.

Columns (9)

Columns of the sessions table
ColumnTypeConstraintsDescription
iduuidprimary key
user_iduuidnot null, references users.id
device_namevarchar(120)
ip_addressvarchar(45)
user_agentvarchar(500)
push_tokenvarchar(255)
created_attimestamptznot null
last_seen_attimestamptznot null
revoked_attimestamptz

Indexes (1)

  • (user_id, last_seen_at)

Relationships