Just to add to Juraj answer:
I guess what you a looking for is this article: Multi-version Upgrades: Alternate Approach.
We've actually upgraded from 7 to 12 that way. The basic idea you upgrade the DB first. And at the end you change the code. If db upgrade went well -> you are 99% successful.
You have to have to all instances installed without DB from 8 to 12: 8 -> 8.1 -> 8.2 -> 9.0 -> 10 -> 11 -> 12. You connect the DB to each instance and run the upgrade (run sql upgrade first. then start the the admin with upgrade file copied in site folder . check the log for DB Upgrade to xx.0 START and FINISH). Anyway follow the article.
- clean up object history and version history tables (for example like this). They are not upgraded anyway. usually these are the biggest tables.
- Backup DB on each step.
- You may shrink the DB (we have over 100k nodes with shrinked DB it was about 10 minutes for each version. the upgrade was significantly faster).