Backport `rake db:structure:dump`

https://rails.lighthouseapp.com/projects/8994/tickets/5889
https://gist.github.com/AquaGeek/971720