feat: add scripts for dummy item generation and thumbnail population, fix avatar foreign key constraint on item deletion, and improve admin approve view for empty trash.

This commit is contained in:
x
2026-01-24 17:57:23 +01:00
parent 2be5b33183
commit 7ebb730dd1
2 changed files with 15 additions and 1 deletions

View File

@@ -249,6 +249,17 @@ export default (router, tpl) => {
// Delete DB entries
console.log('[ADMIN DENY] Deleting DB entries...');
try {
// Fix FK constraint: Check if this item is used as an avatar
try {
const fallback = await db`select id from items where active = true limit 1`;
if (fallback.length > 0) {
const safeId = fallback[0].id;
await db`update "user_options" set avatar = ${safeId} where avatar = ${id}`;
}
} catch (fkErr) {
console.error('[ADMIN DENY FK FIX ERROR]', fkErr);
}
await db`delete from "tags_assign" where item_id = ${id}`;
await db`delete from "favorites" where item_id = ${id}`;
await db`delete from "comments" where item_id = ${id}`.catch(() => { });