public static function migrate_config($config, $mappings) {
        $ruleconfig = json_decode($config, true);
        if (is_array($ruleconfig)) {
            foreach ($ruleconfig['competencies'] as $key => $rulecomp) {
                $rulecmpid = $rulecomp['id'];
                if (array_key_exists($rulecmpid, $mappings)) {
                    $ruleconfig['competencies'][$key]['id'] = $mappings[$rulecmpid]->get('id');
                } else {
                    throw new coding_exception("The competency id is not found in the matchids.");
                }
            }
        } else {
            throw new coding_exception("Invalid JSON config rule.");
        }

        return json_encode($ruleconfig);
    }