Navigating the Challenges of Legacy Code: A Success Story in Database Scalability