One part of me wonders whether this would’ve been caught earlier if I spent some more time analizing the possible approaches for this refactor before starting. Honestly, I don’t think I would. It’s not like I rushed into the schema changes without any thought, I was mainly thinking about existing data and how extendable and understandable it would be to others. It never occurred to me that the the indices would be an issue. In fact, it was only after I modified the unit tests that ran against a mock database that the problem revealed itself. It sucks that I wasted the effort, but I think this is evident that unit tests that use a real database are the way to go. If I had used a mock, it would’ve been found much later.