Refactor move database to model.rb.