-- 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 BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE, name TEXT NOT NULL, key_hash TEXT NOT NULL, sealed BYTEA NOT NULL, created_at BIGINT NOT NULL, last_used_at BIGINT ); CREATE UNIQUE INDEX idx_device_passwords_key ON device_passwords(key_hash); CREATE INDEX idx_device_passwords_user ON device_passwords(user_id);