fix(db): comprehensive symbol recovery + safety fixes
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 22m1s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 22m1s
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user