-- The artists a person sent to their Lidarr from Sonda, so that a page can say which of them have arrived. An artist -- has arrived when its music is in the library: Sonda notices it when the list is read and keeps the day it first did. -- The name is kept too, because the artist of a request can be removed (an artist only a provider named) while the -- request is still of interest. CREATE TABLE lidarr_requests ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, artist_id INTEGER REFERENCES artists(id) ON DELETE SET NULL, artist_name TEXT NOT NULL, artist_key TEXT NOT NULL, -- storage.SearchKey of the name: how music that arrives is told to be this artist's artist_mbid TEXT, requested_at INTEGER NOT NULL, -- unix seconds, the first time it was sent arrived_at INTEGER -- unix seconds, NULL while there is no music of it ); CREATE UNIQUE INDEX idx_lidarr_requests_artist ON lidarr_requests(user_id, artist_key); CREATE INDEX idx_lidarr_requests_time ON lidarr_requests(user_id, requested_at DESC);