Factor out database connection / migration

Trying to keep bot.rb as simple as possible.