Refactor database config