fix(seed): skip team creation if slug already exists to avoid unique constraint error (#22738)
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
co-authored by
Alex van Andel
parent
f149650911
commit
751aa62935
@@ -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