I'd suggest checking out fellow Kentico Xperience MVP Brian McKeiver's Github repo. He has some SQL scripts you can run to help with this. The script he has is for v8, but I believe it's very similar for v12. Very important and he specifies this multiple times, make sure you take backups before you run these scripts.