Scheduling infrastructure for absolutely everyone.
fix: update seed-insights.ts Prisma connection handling for v6.16 (#24660)
Eunjae Leefcd9480f9f9c
diff --git a/scripts/seed-insights.ts b/scripts/seed-insights.tsindex 64413c8f9ee..ee3757a0374 100644--- a/scripts/seed-insights.ts+++ b/scripts/seed-insights.ts@@ -3,8 +3,8 @@ import { v4 as uuidv4 } from "uuid";import dayjs from "@calcom/dayjs";import { hashPassword } from "@calcom/lib/auth/hashPassword";+import { prisma } from "@calcom/prisma";import type { Prisma } from "@calcom/prisma/client";-import { prisma } from "@calcom/prisma/client";import { BookingStatus, AssignmentReasonEnum } from "@calcom/prisma/enums";import { seedAttributes, seedRoutingFormResponses, seedRoutingForms } from "./seed-utils";@@ -367,33 +367,27 @@ async function main() {}async function runMain() {- await prisma.$connect();- await main();-}+ await main()+ .catch(async (e) => {+ console.error(e);+ await prisma.user.deleteMany({+ where: {+ email: {+ in: ["insights@example", "[email protected]"],+ },+ },+ });-runMain()- .then(async () => {- await prisma.$disconnect();- })- .catch(async (e) => {- console.error(e);- await prisma.user.deleteMany({- where: {- email: {- in: ["insights@example", "[email protected]"],+ await prisma.team.deleteMany({+ where: {+ slug: "insights",},- },- });+ });- await prisma.team.deleteMany({- where: {- slug: "insights",- },+ await prisma.$disconnect();+ process.exit(1);});-- await prisma.$disconnect();- process.exit(1);- });+}/*** This will create many users in insights teams with bookings 1y in the past@@ -530,24 +524,34 @@ async function createPerformanceData() {}}-async function runSeed() {+async function runPerformanceData() {+ await createPerformanceData()+ .catch(async (e) => {+ console.error(e);+ await prisma.user.deleteMany({+ where: {+ username: {+ contains: "insights-user-",+ },+ },+ });+ await prisma.$disconnect();+ process.exit(1);+ });+}++async function runEverything() {await prisma.$connect();- await createPerformanceData();++ await runMain();+ await runPerformanceData();}-runSeed()- .then(async () => {- await prisma.$disconnect();- })- .catch(async (e) => {+runEverything()+ .catch((e) => {console.error(e);- await prisma.user.deleteMany({- where: {- username: {- contains: "insights-user-",- },- },- });- await prisma.$disconnect();process.exit(1);+ })+ .finally(async () => {+ await prisma.$disconnect();});