Refactor database.