Adds name and missing relationship to seeder (#688)

Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
pull/707/head^2
Omar López 2021-09-21 03:57:01 -06:00 committed by GitHub
parent c0330acd83
commit 75d6e174e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -53,7 +53,7 @@ async function createBookingForEventType(opts: {
} }
async function createUserAndEventType(opts: { async function createUserAndEventType(opts: {
user: { email: string; password: string; username: string; plan: UserPlan }; user: { email: string; password: string; username: string; plan: UserPlan; name: string };
eventTypes: Array<Prisma.EventTypeCreateArgs["data"]>; eventTypes: Array<Prisma.EventTypeCreateArgs["data"]>;
}) { }) {
const userData: Prisma.UserCreateArgs["data"] = { const userData: Prisma.UserCreateArgs["data"] = {
@ -74,6 +74,7 @@ async function createUserAndEventType(opts: {
for (const rawData of opts.eventTypes) { for (const rawData of opts.eventTypes) {
const eventTypeData: Prisma.EventTypeCreateArgs["data"] = { ...rawData }; const eventTypeData: Prisma.EventTypeCreateArgs["data"] = { ...rawData };
eventTypeData.userId = user.id; eventTypeData.userId = user.id;
eventTypeData.users = { connect: { id: user.id } };
const eventType = await prisma.eventType.findFirst({ const eventType = await prisma.eventType.findFirst({
where: { where: {
@ -114,6 +115,7 @@ async function main() {
email: "free@example.com", email: "free@example.com",
password: "free", password: "free",
username: "free", username: "free",
name: "Free Example",
plan: "FREE", plan: "FREE",
}, },
eventTypes: [ eventTypes: [
@ -135,6 +137,7 @@ async function main() {
email: "free-first-hidden@example.com", email: "free-first-hidden@example.com",
password: "free-first-hidden", password: "free-first-hidden",
username: "free-first-hidden", username: "free-first-hidden",
name: "Free First Hidden Example",
plan: "FREE", plan: "FREE",
}, },
eventTypes: [ eventTypes: [
@ -154,6 +157,7 @@ async function main() {
await createUserAndEventType({ await createUserAndEventType({
user: { user: {
email: "pro@example.com", email: "pro@example.com",
name: "Pro Example",
password: "pro", password: "pro",
username: "pro", username: "pro",
plan: "PRO", plan: "PRO",
@ -187,6 +191,7 @@ async function main() {
email: "trial@example.com", email: "trial@example.com",
password: "trial", password: "trial",
username: "trial", username: "trial",
name: "Trial Example",
plan: "TRIAL", plan: "TRIAL",
}, },
eventTypes: [ eventTypes: [