by Ray Hinton.
I hope that you're able to find a cause or solution for this seemingly intricate problem, but just in case it is possibly something this simple: are you trying to go directly from 2.7.x to 3.6.x? My understanding is that "you can only upgrade to Moodle 3.6 from Moodle 3.1 or later. If upgrading from earlier versions, you must upgrade to 3.1 as a first step."
In your case, probably upgrading the old 2.7 site to 3.1, then using that data to migrate to your new 3.6 site.
If you're already doing that, then just disregard me. ![smile smile]()
Given the pattern you are describing, though, I wonder if there was some change in the database structure for course access records, role assignments, etc.