fix(db): comprehensive symbol recovery + safety fixes
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 22m1s

This commit is contained in:
Pepe Ziberi
2026-05-20 15:05:44 +02:00
parent fdd928720a
commit a53f77c97c
9 changed files with 738 additions and 206 deletions

View File

@@ -115,15 +115,10 @@ async function main() {
// Deleting would either break references (tenant symbols become 404s)
// or cascade-delete tenant symbols. Instead we upsert by fileKey.
// Clean up empty global categories
const oldGlobalCats = await prisma.iconCategory.findMany({ where: { tenantId: null } })
for (const oldCat of oldGlobalCats) {
const remaining = await prisma.iconAsset.count({ where: { categoryId: oldCat.id } })
if (remaining === 0) {
await prisma.iconCategory.delete({ where: { id: oldCat.id } }).catch(() => {})
}
}
// Create new global categories
// NOTE: We intentionally do NOT delete any icon categories here.
// Tenant-specific categories may reference them, and deleting could
// orphan user data. Empty categories are harmless.
// Create or update global categories
const catMap = {}
for (const def of catDefs) {
const cat = await prisma.iconCategory.upsert({