-- The play queue a Subsonic app saves (savePlayQueue) so another app or -- device can pick up where it left off (getPlayQueue): one queue per user, -- the songs in order, the one playing and how far into it. track_ids is not -- a foreign key: a song removed from the library drops out of the queue -- when it is read, rather than blocking the removal. CREATE TABLE play_queues ( user_id uuid PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE, track_ids uuid[] NOT NULL DEFAULT '{}', current_track_id uuid, position_ms bigint NOT NULL DEFAULT 0, changed_at timestamptz NOT NULL DEFAULT now(), -- The app that saved it, from the Subsonic c parameter. changed_by text NOT NULL DEFAULT '' );