fix: seed script command (#24668)

* feat: add seed-all command to run all seed scripts

- Add seed-all command to packages/prisma/package.json
- Create scripts/seed-all.ts to run seed.ts, seed-insights.ts, and seed-pbac-organization.ts in sequence
- Update Prisma configuration to use seed-all as the default seed command
- Add GitHub workflow to test seed-all command with a real PostgreSQL database

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

* fix: use correct path resolution in seed-all script

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

* fix: simplify database verification step in test workflow

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

* refactor: use seed-all in cache-db action instead of separate workflow

- Update cache-db action to use seed-all command
- Remove test-seed-all.yml workflow as requested

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

* fix error

* change command name

* fix integration tests

* run basic seed by default

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
Eunjae Lee
2025-10-28 10:56:52 +00:00
committed by GitHub
co-authored by Devin AI Keith Williams
parent 89cc175d73
commit 3418a25a85
3 changed files with 37 additions and 10 deletions
@@ -4,7 +4,7 @@ import { createMocks } from "node-mocks-http";
import { describe, expect, it, beforeAll } from "vitest";
import { ZodError } from "zod";
import prisma from "@calcom/prisma";
import { prisma } from "@calcom/prisma";
import { handler } from "../../../pages/api/bookings/_get";
@@ -217,6 +217,22 @@ describe("GET /api/bookings", async () => {
describe("Expand feature to add relational data in return payload", () => {
it("Returns only team data when expand=team is set", async () => {
const adminUser = await prisma.user.findFirstOrThrow({ where: { email: "owner1-acme@example.com" } });
// Find a team booking and a non-team booking from seed data
const team1 = await prisma.team.findFirst({ where: { slug: "team1" } });
const teamEventType = await prisma.eventType.findFirst({
where: { teamId: team1?.id },
include: { bookings: true },
});
const teamBooking = teamEventType?.bookings[0];
const nonTeamBooking = await prisma.booking.findFirst({
where: {
eventType: { teamId: null },
userId: proUser.id,
},
});
const { req } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
method: "GET",
query: {
@@ -229,14 +245,23 @@ describe("GET /api/bookings", async () => {
req.isOrganizationOwnerOrAdmin = true;
const responseData = await handler(req);
console.log("bookings=>", responseData.bookings);
responseData.bookings.forEach((booking) => {
if (booking.id === 31) expect(booking.eventType?.team?.slug).toBe("team1");
if (booking.id === 19) {
// The team field can be either null or undefined due to nullish() in the schema
expect(booking.eventType?.team === null || booking.eventType?.team === undefined).toBe(true);
// Verify team booking has team data
if (teamBooking) {
const returnedTeamBooking = responseData.bookings.find((b) => b.id === teamBooking.id);
expect(returnedTeamBooking?.eventType?.team?.slug).toBe("team1");
}
// Verify non-team booking has null/undefined team
if (nonTeamBooking) {
const returnedNonTeamBooking = responseData.bookings.find((b) => b.id === nonTeamBooking.id);
if (returnedNonTeamBooking) {
expect(
returnedNonTeamBooking.eventType?.team === null ||
returnedNonTeamBooking.eventType?.team === undefined
).toBe(true);
}
});
}
});
});
@@ -724,10 +724,11 @@ describe("InsightsBookingService Integration Tests", () => {
});
const baseConditions = await service.getBaseConditions();
const results = await prisma.$queryRaw<{ id: number }[]>`
const query = Prisma.sql`
SELECT id FROM "BookingTimeStatusDenormalized"
WHERE ${baseConditions}
`;
const results = await prisma.$queryRaw<{ id: number }[]>(query);
// Should return the user booking since it matches both conditions
expect(results).toEqual([
+2 -1
View File
@@ -18,6 +18,7 @@
"post-install": "yarn generate-schemas",
"seed-app-store": "ts-node --transpile-only ../../scripts/seed-app-store.ts",
"delete-app": "ts-node --transpile-only ./delete-app.ts",
"seed-basic": "ts-node --transpile-only ../../scripts/seed.ts",
"seed-insights": "ts-node --transpile-only ../../scripts/seed-insights.ts",
"seed-pbac": "ts-node --transpile-only ../../scripts/seed-pbac-organization.ts"
},
@@ -45,6 +46,6 @@
"zod-utils.ts"
],
"prisma": {
"seed": "ts-node --transpile-only ../../scripts/seed.ts"
"seed": "yarn seed-basic"
}
}