From f3284f581ff18a37ecdcface587b4a03236b1861 Mon Sep 17 00:00:00 2001 From: Alana Anjos Date: Mon, 6 Jul 2026 05:29:29 -0300 Subject: [PATCH 1/2] docs: add windows/powershell setup troubleshooting for prisma (#29707) Adds a note explaining how to manually push schema using PowerShell when Turbo fails to pass environment variables down to the prisma workspace. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ab4d9b5667c8ce..4bfd00c01597ec 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ for Logger level to be set at info, for example. If you don't want to create a local DB. Then you can also consider using services like railway.app, Northflank or render. + - [Setup postgres DB with railway.app](https://docs.railway.app/guides/postgresql) - [Setup postgres DB with Northflank](https://northflank.com/guides/deploy-postgres-database-on-northflank) @@ -235,6 +236,15 @@ for Logger level to be set at info, for example. yarn workspace @calcom/prisma db-deploy ``` + **Note for Windows/PowerShell users:** If running the database deployment scripts fails with an error stating `Environment variable not found: DATABASE_DIRECT_URL`, Turbo might be failing to inject the root `.env` variables. You can bypass this by executing the commands directly from the prisma package directory in PowerShell: + +```powershell +cd packages/prisma +$env:DATABASE_URL="postgresql://postgres:YOUR_PASSWORD@localhost:5432/postgres"; $env:DATABASE_DIRECT_URL="postgresql://postgres:YOUR_PASSWORD@localhost:5432/postgres" +npx prisma db push +cd ../.. +``` + 4. Run [mailhog](https://github.com/mailhog/MailHog) to view emails sent during development > **_NOTE:_** Required when `E2E_TEST_MAILHOG_ENABLED` is "1" From ca90ca2c94536c7fac97e4e829cdfe18624c7f10 Mon Sep 17 00:00:00 2001 From: Anirban Singha <143536290+SinghaAnirban005@users.noreply.github.com> Date: Mon, 6 Jul 2026 14:10:17 +0530 Subject: [PATCH 2/2] refactor(app-store): move credential query to repository pattern (#29724) * refactor(app-store): move credential query to repository pattern * chore: removed unused imports --- .../PrismaCredentialRepository.ts | 40 +++++++++++++++++++ packages/app-store/server.ts | 27 +++---------- 2 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 packages/app-store/repositories/PrismaCredentialRepository.ts diff --git a/packages/app-store/repositories/PrismaCredentialRepository.ts b/packages/app-store/repositories/PrismaCredentialRepository.ts new file mode 100644 index 00000000000000..0901159f51ac3b --- /dev/null +++ b/packages/app-store/repositories/PrismaCredentialRepository.ts @@ -0,0 +1,40 @@ +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; +import { prisma } from "@calcom/prisma"; +import type { Prisma } from "@calcom/prisma/client"; +import type { AppCategories } from "@calcom/prisma/client"; +import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; + +export class PrismaCredentialRepository { + constructor(private readonly prismaClient: typeof prisma){} + + async findNonDelegationCredentialsByAppCategories({ + idToSearchObject, + appCategories, + }: { + idToSearchObject: Prisma.CredentialWhereInput; + appCategories: AppCategories[]; + }){ + + const credentials = await this.prismaClient.credential.findMany({ + where: { + ...idToSearchObject, + app: { + categories: { + hasSome: appCategories + } + } + }, + select: { + ...credentialForCalendarServiceSelect, + team: { + select: { + name: true + } + } + } + }) + + + return buildNonDelegationCredentials(credentials) + } +} \ No newline at end of file diff --git a/packages/app-store/server.ts b/packages/app-store/server.ts index a6729e9badd0be..33e068d383b882 100644 --- a/packages/app-store/server.ts +++ b/packages/app-store/server.ts @@ -2,11 +2,10 @@ import type { TFunction } from "i18next"; import { enrichUserWithDelegationConferencingCredentialsWithoutOrgId } from "@calcom/app-store/delegationCredential"; import { defaultVideoAppCategories } from "@calcom/app-store/utils"; -import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { AppCategories } from "@calcom/prisma/enums"; -import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; +import { PrismaCredentialRepository } from "./repositories/PrismaCredentialRepository"; import getEnabledAppsFromCredentials from "./_utils/getEnabledAppsFromCredentials"; import { defaultLocations } from "./locations"; @@ -62,23 +61,10 @@ export async function getLocationGroupedOptions( }); } - const nonDelegationCredentials = await prisma.credential.findMany({ - where: { - ...idToSearchObject, - app: { - categories: { - hasSome: defaultVideoAppCategories, - }, - }, - }, - select: { - ...credentialForCalendarServiceSelect, - team: { - select: { - name: true, - }, - }, - }, + const credentialRepository = new PrismaCredentialRepository(prisma); + const nonDelegationCredentials = await credentialRepository.findNonDelegationCredentialsByAppCategories({ + idToSearchObject, + appCategories: defaultVideoAppCategories, }); let credentials; @@ -94,8 +80,7 @@ export async function getLocationGroupedOptions( ); credentials = allCredentials; } else { - // TODO: We can avoid calling buildNonDelegationCredentials here by moving the above prisma query to the repository and doing it there - credentials = buildNonDelegationCredentials(nonDelegationCredentials); + credentials = nonDelegationCredentials; } const integrations = await getEnabledAppsFromCredentials(credentials, { filterOnCredentials: true });