Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

make defaultFolderId required too, move programFolder creation into transaction

Steven Tey609390cc998e
diff --git a/apps/web/lib/actions/partners/create-program.ts b/apps/web/lib/actions/partners/create-program.ts
index 39199f0a74..9f7665a10f 100644
--- a/apps/web/lib/actions/partners/create-program.ts
+++ b/apps/web/lib/actions/partners/create-program.ts
@@ -57,30 +57,30 @@ export const createProgram = async ({
await getDomainOrThrow({ workspace, domain });
- const programFolder = await prisma.folder.upsert({
- where: {
- name_projectId: {
+ // create a new program
+ const program = await prisma.$transaction(async (tx) => {
+ const programFolder = await tx.folder.upsert({
+ where: {
+ name_projectId: {
+ name: "Partner Links",
+ projectId: workspace.id,
+ },
+ },
+ update: {},
+ create: {
+ id: createId({ prefix: "fold_" }),
name: "Partner Links",
projectId: workspace.id,
- },
- },
- update: {},
- create: {
- id: createId({ prefix: "fold_" }),
- name: "Partner Links",
- projectId: workspace.id,
- accessLevel: "write",
- users: {
- create: {
- userId: user.id,
- role: "owner",
+ accessLevel: "write",
+ users: {
+ create: {
+ userId: user.id,
+ role: "owner",
+ },
},
},
- },
- });
+ });
- // create a new program
- const program = await prisma.$transaction(async (tx) => {
const programId = createId({ prefix: "prog_" });
const defaultGroupId = createId({ prefix: "grp_" });
diff --git a/packages/prisma/schema/program.prisma b/packages/prisma/schema/program.prisma
index 6c2d3b0a0a..3cb00b85c0 100644
--- a/packages/prisma/schema/program.prisma
+++ b/packages/prisma/schema/program.prisma
@@ -31,7 +31,7 @@ enum PartnerUrlValidationMode {
model Program {
id String @id @default(cuid())
workspaceId String
- defaultFolderId String?
+ defaultFolderId String
defaultGroupId String
name String
slug String @unique