OXYGENHUB
# a3ba7cc10673 oxygenhub / crates / hub / migrations / 0068_sessions.sql
674 B · SQL · last changed Sessions are server-side records: random ids, expiry, listed and ended per browser 20 days ago source blame history raw
1
-- Sessions as server-side records (oxygenhub#223). The cookie holds a
2
-- random id; only its hash is kept here. A session is good while its salt
3
-- matches the account's (a new password or "sign out everywhere" ends them
4
-- all), it has been used in the last 14 days, and it is under 30 days old.
5
CREATE TABLE sessions (
6
    id INTEGER PRIMARY KEY,
7
    account_id INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
8
    hash TEXT NOT NULL UNIQUE,
9
    salt TEXT NOT NULL,
10
    created_ms INTEGER NOT NULL,
11
    seen_ms INTEGER NOT NULL,
12
    address TEXT NOT NULL DEFAULT '',
13
    agent TEXT NOT NULL DEFAULT ''
14
);
15
CREATE INDEX sessions_account ON sessions(account_id);