Take a look at hexagon pattern from Spotify. Once you start testing the user contract of your services against real databases (testcontainners is a good option), then you can change all the internals and be sure that the externals will work.
https://engineering.atspotify.com/2018/01/testing-of-microse...