more name checks and add proper soft deletes to bots

This commit is contained in:
nytmyr
2024-12-22 00:05:45 -06:00
parent 600376274f
commit 2460f78015
3 changed files with 37 additions and 21 deletions
@@ -349,14 +349,25 @@ public:
int bot_data_id
)
{
auto results = db.QueryDatabase(
fmt::format(
std::string query;
if (RuleB(Bots, BotSoftDeletes)) {
query = fmt::format(
"UPDATE {} SET name = SUBSTRING(CONCAT(name, '-deleted-', UNIX_TIMESTAMP()), 1, 64) WHERE {} = {}",
TableName(),
PrimaryKey(),
bot_data_id
);
}
else {
query = fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
bot_data_id
)
);
);
}
auto results = db.QueryDatabase(query);
return (results.Success() ? results.RowsAffected() : 0);
}