![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/public_html/scripts/ |
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function cleanupDuplicateBusiness() {
try {
console.log('๐งน Cleaning up duplicate business profiles...\n');
// Find all ADW Avocats business profiles
const adwProfiles = await prisma.businessProfile.findMany({
where: {
businessName: 'ADW Avocats'
},
include: {
members: true
}
});
console.log(`Found ${adwProfiles.length} ADW Avocats profiles`);
if (adwProfiles.length > 1) {
// Keep the one with members, delete the others
const profileWithMembers = adwProfiles.find(profile => profile.members.length > 0);
const profilesToDelete = adwProfiles.filter(profile => profile.members.length === 0);
if (profileWithMembers && profilesToDelete.length > 0) {
console.log(`Keeping profile with ${profileWithMembers.members.length} members (ID: ${profileWithMembers.id})`);
for (const profile of profilesToDelete) {
console.log(`Deleting duplicate profile (ID: ${profile.id})`);
await prisma.businessProfile.delete({
where: { id: profile.id }
});
}
console.log(`โ
Deleted ${profilesToDelete.length} duplicate profiles`);
}
}
// Verify the cleanup
const remainingProfiles = await prisma.businessProfile.findMany({
where: {
businessName: 'ADW Avocats'
},
include: {
members: true
}
});
console.log(`\n๐ After cleanup: ${remainingProfiles.length} ADW Avocats profiles`);
remainingProfiles.forEach((profile, index) => {
console.log(` ${index + 1}. ID: ${profile.id}, Members: ${profile.members.length}`);
});
} catch (error) {
console.error('Error cleaning up duplicate business profiles:', error);
} finally {
await prisma.$disconnect();
}
}
cleanupDuplicateBusiness();