refactors database creation