The rhyme dates back to the 18th century. It was first recorded, along with many other well-known rhymes in Tommy Thumb, in his Pretty Song Book collection in 1744. There are a few other versions of the song, including one published in 1765 under the name ‘Dickery Dock.