feat: add explicit database upgrade functionality with improved error handling