refactored opening a database to allow for future schema upgrades