From 716090a1322f4cb05275b5810effe45598c655e4 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 21 Oct 2024 04:08:33 +0000 Subject: [PATCH] fix: fix migration incase there is invalid data --- src/NadekoBot/Migrations/MigrationQueries.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Migrations/MigrationQueries.cs b/src/NadekoBot/Migrations/MigrationQueries.cs index ff8cf001b..b14ac1e5a 100644 --- a/src/NadekoBot/Migrations/MigrationQueries.cs +++ b/src/NadekoBot/Migrations/MigrationQueries.cs @@ -70,8 +70,9 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;") public static void AddGuildIdsToWarningPunishment(MigrationBuilder builder) { builder.Sql(""" + DELETE FROM WarningPunishment WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); UPDATE WarningPunishment - SET GuildId = (SELECT GuildId FROM guildconfigs WHERE Id = GuildConfigId); + SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE Id = GuildConfigId); DELETE FROM WarningPunishment as wp WHERE (wp.Count, wp.GuildConfigId) in (