This will work if you have an existing user account, or created a new user or just deleted a few conversations from the messages app. One thing to know is that just because you deleted a conversation doesn't mean the threads are gone. They all kept in the user/library/container/com.apple.iChat folder. I accidently deleted a conversation from my messages app on my mac. I read quite a bit on this and found out some things I'd like to share. Hopefully I'll save you some time and frustration.
1. Try and have the person who you deleted the conversation send you a text or you send them one. Once that happens, the threads should magically reappear in the messages app.
2. If you replace the *.db files (3 of them) and the attachments folder from a backup and and copy them to the messages folder (choose replace), restart your mac and open messages they will also come back from the dates saved. If you don't restart, and open messages, then you will get a blank slate with one new conversation. Rebooting reinitializes the messages database files somehow. Open messages and the newly populated messages app will show your past conversations. Go to 1 if you want to get a deleted conversation.
3. For a new account, do this. First shut down messages. Then grab a backup of the *.db files (3 of them) and the attachments folder from with time machine or go to folder user/library/messages and copy them to the messages folder. Then grab all the com.apple.ichat.* files and copy them to the same location under my user profile. Restart the computer, open messages, and all the conversations were there again in the window and navigable from the date saved.
If you are only seeing phone numbers and not names, restore your contacts as well.
Also there is a link on merging the databases with python. I think it only works on El Cap and the corresponding Darwin version. Couldn't get to work because I'm on Sierra, I think. See here:
https://gist.github.com/nschum/1cf00aee2f1ac8869df4#file-merge-py
If I got something wrong here, please tell me your experience. These are the tricks I used recently and I was satisfied.
What would really be nice is a option letting the user know "Do you really want to delete this conversation" instead of poof its gone.
Hope this helps someone else.