From 1cd02222b93ba7710cb274be07b89f7a89d44ac1 Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Fri, 14 Mar 2025 13:35:54 +1300
Subject: [PATCH] fixed muteuserid cleanup migration

---
 src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql b/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql
index df8efd3..fa8bfcd 100644
--- a/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql
+++ b/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql
@@ -172,6 +172,7 @@ UPDATE Permissions
 SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = Permissions.GuildConfigId);
 
 DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
+    OR (GuildId, UserId) IN (SELECT GuildId, UserId FROM MutedUserId GROUP BY GuildId, UserId HAVING COUNT(*) > 1);
 UPDATE MutedUserId
 SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = MutedUserId.GuildConfigId);