add: Added .cleanupguilddata command which will delete all guildconfigs, xp stats and other data related to any guild the bot is no longer in. This is a highly destructive and irreversible command.

dev: Added cascade deletes to any tables which have guildconfigs FK, as well as to some other missing places
This commit is contained in:
Kwoth
2024-05-18 16:09:54 +00:00
parent 03fb1a5ca2
commit 0c167a9382
28 changed files with 13286 additions and 273 deletions

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using NadekoBot.Db.Models;
namespace NadekoBot.Migrations;
@@ -39,4 +40,15 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;")
throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero");
}
}
public static void GuildConfigCleanup(MigrationBuilder builder)
{
builder.Sql($"""
DELETE FROM "StreamRoleBlacklistedUser" WHERE "StreamRoleSettingsId" is NULL;
""");
builder.Sql($"""
DELETE FROM "DelMsgOnCmdChannel" WHERE "GuildConfigId" is NULL;
""");
}
}