I am sorry, I did not mark this topic as ‘not a support question’ like it should have been. This is not a bug report, I successfully solved my problem. I just wrote this because by solving it I nearly lost my mind. The structure of a database is bad when you need to store serialized data which can be broken after an upgrade.