Refactoring the update database script.