fix: update seed-insights.ts Prisma connection handling for v6.16 (#24660)

* fix: update seed-insights.ts to use correct Prisma import and connection handling

- Change prisma import from named export to default export to match Prisma v6.16 changes
- Update promise chain from .then().catch() to .catch().finally() for proper connection cleanup
- Comment out duplicate runSeed() call that was causing the script to execute twice
- Fixes TypeError: Cannot read properties of undefined (reading '$connect')

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix implementation

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Eunjae Lee
2025-10-23 15:59:05 +00:00
committed by GitHub
co-authored by Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 09ddbe886f
commit fcd9480f9f
+45 -41
View File
@@ -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();
}
runMain()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.user.deleteMany({
where: {
email: {
in: ["insights@example", "insightsuser@example.com"],
await main()
.catch(async (e) => {
console.error(e);
await prisma.user.deleteMany({
where: {
email: {
in: ["insights@example", "insightsuser@example.com"],
},
},
},
});
});
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() {
await prisma.$connect();
await createPerformanceData();
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);
});
}
runSeed()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
async function runEverything() {
await prisma.$connect();
await runMain();
await runPerformanceData();
}
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();
});