Skip to content

Commit 1eb189d

Browse files
committed
Update the schema to include onboardingData on the User and Project
1 parent 23c327e commit 1eb189d

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

apps/webapp/app/models/project.server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { nanoid, customAlphabet } from "nanoid";
22
import slug from "slug";
33
import { $replica, prisma } from "~/db.server";
4-
import type { Project } from "@trigger.dev/database";
5-
import { Organization, createEnvironment } from "./organization.server";
4+
import type { Prisma, Project } from "@trigger.dev/database";
5+
import { type Organization, createEnvironment } from "./organization.server";
66
import { env } from "~/env.server";
77
import { projectCreated } from "~/services/platform.v3.server";
88
export type { Project } from "@trigger.dev/database";
@@ -14,6 +14,7 @@ type Options = {
1414
name: string;
1515
userId: string;
1616
version: "v2" | "v3";
17+
onboardingData?: Prisma.InputJsonValue;
1718
};
1819

1920
export class ExceededProjectLimitError extends Error {
@@ -24,7 +25,7 @@ export class ExceededProjectLimitError extends Error {
2425
}
2526

2627
export async function createProject(
27-
{ organizationSlug, name, userId, version }: Options,
28+
{ organizationSlug, name, userId, version, onboardingData }: Options,
2829
attemptCount = 0
2930
): Promise<Project & { organization: Organization }> {
3031
//check the user has permissions to do this
@@ -84,6 +85,7 @@ export async function createProject(
8485
name,
8586
userId,
8687
version,
88+
onboardingData,
8789
},
8890
attemptCount + 1
8991
);
@@ -100,6 +102,7 @@ export async function createProject(
100102
},
101103
externalRef: `proj_${externalRefGenerator()}`,
102104
version: version === "v3" ? "V3" : "V2",
105+
onboardingData: onboardingData ?? undefined,
103106
},
104107
include: {
105108
organization: {

apps/webapp/app/models/user.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ export function updateUser({
332332
email,
333333
marketingEmails,
334334
referralSource,
335+
onboardingData,
335336
}: Pick<User, "id" | "name" | "email"> & {
336337
marketingEmails?: boolean;
337338
referralSource?: string;
339+
onboardingData?: Prisma.InputJsonValue;
338340
}) {
339341
return prisma.user.update({
340342
where: { id },
341-
data: { name, email, marketingEmails, referralSource, confirmedBasicDetails: true },
343+
data: { name, email, marketingEmails, referralSource, onboardingData, confirmedBasicDetails: true },
342344
});
343345
}
344346

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- AlterTable
2+
ALTER TABLE "public"."User" ADD COLUMN "onboardingData" JSONB;
3+
4+
-- AlterTable
5+
ALTER TABLE "public"."Project" ADD COLUMN "onboardingData" JSONB;

internal-packages/database/prisma/schema.prisma

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ model User {
4343
confirmedBasicDetails Boolean @default(false)
4444
4545
referralSource String?
46+
onboardingData Json?
4647
4748
orgMemberships OrgMember[]
4849
sentInvites OrgMemberInvite[]
@@ -411,6 +412,7 @@ model Project {
411412
customerQueries CustomerQuery[]
412413
413414
buildSettings Json?
415+
onboardingData Json?
414416
taskScheduleInstances TaskScheduleInstance[]
415417
metricsDashboards MetricsDashboard[]
416418
}

0 commit comments

Comments
 (0)