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:
@@ -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(() => { });
|
||||
|
||||
Reference in New Issue
Block a user