Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🍃 Update seed script (#917)
Luke Vella768b73c89abb
diff --git a/packages/database/prisma/seed.ts b/packages/database/prisma/seed.tsindex eb648e103..353dec76b 100644--- a/packages/database/prisma/seed.ts+++ b/packages/database/prisma/seed.ts@@ -1,5 +1,6 @@import { faker } from "@faker-js/faker";import { PrismaClient } from "@prisma/client";+import dayjs from "dayjs";const prisma = new PrismaClient();@@ -7,15 +8,7 @@ const randInt = (max = 1, floor = 0) => {return Math.round(Math.random() * max) + floor;};-async function main() {- // Create some users- const user = await prisma.user.create({- data: {- name: "Dev User",- email: "[email protected]",- },- });-+async function createPollsForUser(userId: string) {// Create some pollsconst polls = await Promise.all(Array.from({ length: 20 }).map(async (_, i) => {@@ -34,7 +27,7 @@ async function main() {deadline: faker.date.future(),user: {connect: {- id: user.id,+ id: userId,},},timeZone: duration !== 0 ? "America/New_York" : undefined,@@ -102,8 +95,59 @@ async function main() {});}}+}++async function main() {+ // Create some users+ const freeUser = await prisma.user.create({+ data: {+ name: "Dev User",+ email: "[email protected]",+ timeZone: "America/New_York",+ },+ });++ const proUser = await prisma.user.create({+ data: {+ name: "Pro User",+ email: "[email protected]",+ customerId: "cus_123",+ subscription: {+ create: {+ id: "sub_123",+ active: true,+ priceId: "price_123",+ periodStart: new Date(),+ periodEnd: dayjs().add(1, "year").toDate(),+ },+ },+ },+ });++ const proUserLegacy = await prisma.user.create({+ data: {+ name: "Pro User Legacy",+ email: "[email protected]",+ },+ });++ await prisma.userPaymentData.create({+ data: {+ userId: proUserLegacy.id,+ status: "active",+ endDate: dayjs().add(1, "year").toDate(),+ planId: "pro_123",+ updateUrl: "https://example.com/update",+ cancelUrl: "https://example.com/cancel",+ subscriptionId: "sub_123",+ },+ });++ [freeUser.id, proUser.id, proUserLegacy.id].forEach(async (userId) => {+ await createPollsForUser(userId);+ });- console.info(`Seeded database with user: ${user.email}`);+ console.info(`Seeded data`);}main()