From 1038576ff4f6806214b010d9a895d94480575be3 Mon Sep 17 00:00:00 2001 From: Toastie Date: Wed, 23 Oct 2024 19:27:39 +1300 Subject: [PATCH] fix migration incase there is invalid data --- src/EllieBot/Migrations/MigrationQueries.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/EllieBot/Migrations/MigrationQueries.cs b/src/EllieBot/Migrations/MigrationQueries.cs index 7fc2ff2..105f766 100644 --- a/src/EllieBot/Migrations/MigrationQueries.cs +++ b/src/EllieBot/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 (