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:
Sahitya Chandra
2025-07-25 12:34:21 +00:00
committed by GitHub
co-authored by Alex van Andel
parent f149650911
commit 751aa62935
+13
View File
@@ -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>;