diff --git a/src/NadekoBot/Migrations/MigrationQueries.cs b/src/NadekoBot/Migrations/MigrationQueries.cs
index 5312334e4..1a9586448 100644
--- a/src/NadekoBot/Migrations/MigrationQueries.cs
+++ b/src/NadekoBot/Migrations/MigrationQueries.cs
@@ -21,15 +21,17 @@ public static class MigrationQueries
INNER JOIN GuildConfigs as GC ON GN.GuildConfigId = GC.Id;
INSERT INTO Sar (GuildId, RoleId, SarGroupId, LevelReq)
- SELECT SAR.GuildId, SAR.RoleId, MIN(SG2.Id), MIN(SAR.LevelRequirement)
- FROM SelfAssignableRoles as SAR
- INNER JOIN (SELECT GuildId FROM GroupName as gn
- INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id
- ) as SG
- ON SG.GuildId = SAR.GuildId
- INNER JOIN GroupName as SG2
- ON SG2.Number = SAR."Group"
- GROUP BY SAR.GuildId, SAR.RoleId;
+ SELECT SAR.GuildId, SAR.RoleId, SG2.Id, MIN(SAR.LevelRequirement)
+ FROM SelfAssignableRoles as SAR
+ INNER JOIN (SELECT GuildId FROM GroupName as gn
+ INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id
+ ) as SG
+ ON SG.GuildId = SAR.GuildId
+ INNER JOIN (SELECT gn.Id, Number FROM GroupName as gn
+ INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id
+ ) as SG2
+ ON SG2.Number = SAR."Group"
+ GROUP BY SAR.GuildId, SAR.RoleId;
INSERT INTO SarAutoDelete (GuildId, IsEnabled)
SELECT GuildId, AutoDeleteSelfAssignedRoleMessages FROM GuildConfigs WHERE AutoDeleteSelfAssignedRoleMessages = TRUE;
diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj
index 49fb7a564..cdfc7925a 100644
--- a/src/NadekoBot/NadekoBot.csproj
+++ b/src/NadekoBot/NadekoBot.csproj
@@ -4,7 +4,7 @@
enable
true
en
- 5.2.0
+ 5.2.1
$(MSBuildProjectDirectory)