diff --git a/db/migrations/5.1.4_fix_my_courses_group_config.php b/db/migrations/5.1.4_fix_my_courses_group_config.php
index a7a972cb74e90fc68c51ec1779871cccf1069446..bc761e99a924a1d4023d460c6cfeaa6f31131d09 100644
--- a/db/migrations/5.1.4_fix_my_courses_group_config.php
+++ b/db/migrations/5.1.4_fix_my_courses_group_config.php
@@ -22,7 +22,7 @@ final class FixMyCoursesGroupConfig extends Migration
                     }
                 }
 
-                if ($changed) {
+                if ($value->value[0] === '{' || $changed) {
                     $value->value = json_encode(array_values($groups));
                     $value->store();
                 }