2016-01-20, 20:43
For all those interested, I've made this into a fully (almost) dynamic script which will (most likely) work on schema changes. Right now it is very much beta, but I'd love to get feedback on it!
http://pastebin.com/wZ7xLe9G
http://pastebin.com/wZ7xLe9G