MDL-38228 upgrade: Rewrite script that fixes corrupt course modules to sequence relation