fix(seed): skip team creation if slug already exists to avoid unique constraint error (#22738)
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
1 parent
f149650911
commit
751aa62935
1 file changed
+13
@@ -293,6 +293,19 @@ async function createOrganizationAndAddMembersAndTeams({
|
||||
}[];
|
||||
}) {
|
||||
console.log(`\n🏢 Creating organization "${orgData.name}"`);
|
||||
|
||||
const existingTeam = await prisma.team.findFirst({
|
||||
where: {
|
||||
slug: orgData.slug,
|
||||
parentId: null,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingTeam) {
|
||||
console.log(`Organization with slug '${orgData.slug}' already exists, skipping.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const orgMembersInDb: (User & {
|
||||
inTeams: { slug: string; role: MembershipRole }[];
|
||||
orgMembership: Partial<Membership>;
|
||||
|
||||
Reference in new issue
Block a user