-- An append the phone sent but never heard back about (a timeout, the app -- killed mid-request) stays in its offline queue and is sent again. An -- append is an action, not a state, so the second send would add the songs -- a second time. The phone now names each append with a request id, and -- the server keeps the ids it has applied here: a send whose id is already -- recorded for the playlist changes nothing. Rows older than 30 days are -- pruned as new appends arrive; a queued write is replayed long before that. CREATE TABLE playlist_append_requests ( playlist_id uuid NOT NULL REFERENCES playlists(id) ON DELETE CASCADE, request_id uuid NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (playlist_id, request_id) );