import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() async function main () { try { console.log('Starting custom fields cleanup...') const deletedValues = await prisma.customFieldValue.deleteMany({ where: { customField: { OR: [ { typeComposantId: { not: null } }, { typePieceId: { not: null } }, { typeMachineId: { not: null } } ] } } }) console.log(`Deleted ${deletedValues.count} custom field values linked to type-level definitions.`) const deletedFields = await prisma.customField.deleteMany({ where: { OR: [ { typeComposantId: { not: null } }, { typePieceId: { not: null } }, { typeMachineId: { not: null } } ] } }) console.log(`Deleted ${deletedFields.count} custom field definitions linked to model types.`) console.log('Cleanup complete.') } catch (error) { console.error('Cleanup failed:', error) process.exitCode = 1 } finally { await prisma.$disconnect() } } main()