chore(profiles): guard default-profile creation

This commit is contained in:
Matthieu
2025-09-19 15:15:06 +02:00
parent 9fdb888d24
commit b8559be031

View File

@@ -102,7 +102,10 @@ export class ProfilesService implements OnModuleInit {
}
private async ensureDefaultProfile() {
const count = await this.prisma.profile.count({ where: { isActive: true } })
const count = await this.prisma.profile.count({ where: { isActive: true } }).catch((err) => {
console.error('Failed to count profiles during ensureDefaultProfile:', err.message)
return 0
})
if (count > 0) return
const firstName = process.env.DEFAULT_PROFILE_FIRST_NAME?.trim() || 'Admin'
@@ -114,6 +117,8 @@ export class ProfilesService implements OnModuleInit {
lastName,
isActive: true,
},
}).catch((err) => {
console.error('Failed to create default profile:', err.message)
})
}
}