-- A password is what lets a person sign in to the web UI. NULL means the user -- has none and can only use API keys, which is every user created before this. ALTER TABLE users ADD COLUMN password_hash TEXT; -- A session is a browser's credential, the cookie counterpart of an API key: -- only the hash of the token is stored. expires_at slides forward while the -- session is in use, so an on-call phone stays signed in. CREATE TABLE sessions ( id INTEGER PRIMARY KEY AUTOINCREMENT, token_hash TEXT NOT NULL UNIQUE, user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, created_at INTEGER NOT NULL, last_seen_at INTEGER NOT NULL, expires_at INTEGER NOT NULL, user_agent TEXT ); CREATE INDEX idx_sessions_user ON sessions(user_id);