While it won’t help your specific issue, I have a similar issue and I think they are linked
My thinking here is the software over time has added a collection of “features” that are exhibited in the database structure itself and the code page is expecting these changes to reside in the database to properly run.
I wonder if there is a need to change the order of updates to migrate the database first (after backup set of course) and then run all the code against the upgraded database. That way all the functions that are expecting a certain database structure will work ok.
Not sure if this is the right approach, just a hunch I have right now.