Move db version logic to library