fix: seed script (#13868)

This commit is contained in:
Udit Takkar
2024-02-26 14:31:25 +00:00
committed by GitHub
parent 2051e87436
commit 0d68767d0a
+17 -6
View File
@@ -38,13 +38,9 @@ export async function createUserAndEventType({
appId: string;
} | null)[];
}) {
const { password, ...restOfUser } = user;
const userData = {
...user,
password: {
create: {
hash: await hashPassword(user.password),
},
},
...restOfUser,
emailVerified: new Date(),
completedOnboarding: user.completedOnboarding ?? true,
locale: "en",
@@ -69,6 +65,21 @@ export async function createUserAndEventType({
create: userData,
});
await prisma.userPassword.upsert({
where: { userId: theUser.id },
update: {
hash: await hashPassword(user.password),
},
create: {
hash: await hashPassword(user.password),
user: {
connect: {
id: theUser.id,
},
},
},
});
console.log(
`👤 Upserted '${user.username}' with email "${user.email}" & password "${user.password}". Booking page 👉 ${process.env.NEXT_PUBLIC_WEBAPP_URL}/${user.username}`
);