[#43716787] Fixed the database migration issue and refactored code