-- The passwords a person makes for the apps and devices that connect to their server (OpenSubsonic clients). A password -- opens the music API and nothing else. Token login needs the secret itself, so it is kept sealed (sealed), and a hash of -- it (key_hash) finds the device of an API key. CREATE TABLE device_passwords ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, name TEXT NOT NULL, key_hash TEXT NOT NULL, sealed BLOB NOT NULL, created_at INTEGER NOT NULL, -- unix seconds last_used_at INTEGER -- unix seconds, NULL until it is used ); CREATE UNIQUE INDEX idx_device_passwords_key ON device_passwords(key_hash); CREATE INDEX idx_device_passwords_user ON device_passwords(user_id);