fix migration incase there is invalid data

This commit is contained in:
Toastie (DCS Team) 2024-10-23 19:27:39 +13:00
parent 17d4d2a925
commit 1038576ff4
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -70,8 +70,9 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;")
public static void AddGuildIdsToWarningPunishment(MigrationBuilder builder) public static void AddGuildIdsToWarningPunishment(MigrationBuilder builder)
{ {
builder.Sql(""" builder.Sql("""
DELETE FROM WarningPunishment WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
UPDATE WarningPunishment 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 DELETE FROM WarningPunishment as wp
WHERE (wp.Count, wp.GuildConfigId) in ( WHERE (wp.Count, wp.GuildConfigId) in (