That is also an unfortunate design on Matrix' part. I had no problem migrating data when changing from ejabberd to Prosody. Because they are open source, so it's not really a problem to export to ad-hoc text and import again.
But Matrix closely follows proprietary products in its design, and the database is treated like some internal affair that you are not to meddle in. You'd have to reverse engineer the data format from source code, which is not practical for hobbyists.
AFAIR there is a doc about migration from synapse, that they promised to automate once dendrite would be production ready, which it never became.