-- Add unique constraint to prevent duplicate favorites per user -- First, remove any existing duplicates (keep the oldest one) DELETE FROM favorites WHERE rowid NOT IN ( SELECT MIN(rowid) FROM favorites GROUP BY userid, path ); -- Add unique index to enforce constraint CREATE UNIQUE INDEX idx_favorites_unique ON favorites(userid, path);