Skip to content

Commit b4ae808

Browse files
authored
Upgrade Prisma to v7 (#1064)
1 parent 9f96b23 commit b4ae808

71 files changed

Lines changed: 758 additions & 312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
env:
1919
NODE_ENV: test
2020
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
21-
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
21+
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
2222

2323
strategy:
2424
matrix:

.github/workflows/e2e-custom-base-port-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
env:
1818
NODE_ENV: test
1919
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
20-
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
20+
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
2121
NEXT_PUBLIC_STACK_PORT_PREFIX: "67"
2222

2323
strategy:

.github/workflows/e2e-source-of-truth-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
2020
STACK_OVERRIDE_SOURCE_OF_TRUTH: '{"type": "postgres", "connectionString": "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/source-of-truth-db?schema=sot-schema"}'
2121
STACK_TEST_SOURCE_OF_TRUTH: true
22-
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
22+
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
2323

2424
strategy:
2525
matrix:

apps/backend/.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ STACK_EMAIL_BRANCHING_DISABLE_QUEUE_SENDING=# set to 'true' to throw an error in
5555
# Database
5656
# For local development: `docker run -it --rm -e POSTGRES_PASSWORD=password -p "8128:5432" postgres`
5757
STACK_DATABASE_CONNECTION_STRING=# enter your connection string here. For local development: `postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe`
58-
STACK_DIRECT_DATABASE_CONNECTION_STRING=# enter your direct (unpooled or session mode) database connection string here. For local development: same as above
5958

6059
# Webhooks
6160
STACK_SVIX_SERVER_URL=# For prod, leave it empty. For local development, use `http://localhost:8113`

apps/backend/.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ STACK_SPOTIFY_CLIENT_SECRET=MOCK
2626

2727
STACK_ALLOW_SHARED_OAUTH_ACCESS_TOKENS=true
2828

29-
STACK_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28/stackframe?connection_limit=20
30-
STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28/stackframe?connection_limit=20
29+
STACK_DATABASE_CONNECTION_STRING=postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28/stackframe
30+
STACK_DATABASE_REPLICA_CONNECTION_STRING=postgres://readonly:PASSWORD-PLACEHOLDER--readonlyuqfEC1hmmv@localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28/stackframe
3131

3232
STACK_EMAIL_HOST=127.0.0.1
3333
STACK_EMAIL_PORT=${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}29

apps/backend/next.config.mjs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import createBundleAnalyzer from "@next/bundle-analyzer";
21
import { withSentryConfig } from "@sentry/nextjs";
32

4-
const withBundleAnalyzer = createBundleAnalyzer({
5-
enabled: !!process.env.ANALYZE_BUNDLE,
6-
});
7-
83
const withConfiguredSentryConfig = (nextConfig) =>
94
withSentryConfig(
105
nextConfig,
@@ -101,4 +96,4 @@ const nextConfig = {
10196
},
10297
};
10398

104-
export default withConfiguredSentryConfig(withBundleAnalyzer(nextConfig));
99+
export default withConfiguredSentryConfig(nextConfig);

apps/backend/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@
5858
"@opentelemetry/sdk-trace-node": "^1.26.0",
5959
"@opentelemetry/semantic-conventions": "^1.27.0",
6060
"@oslojs/otp": "^1.1.0",
61-
"@prisma/adapter-neon": "^6.12.0",
62-
"@prisma/adapter-pg": "^6.12.0",
63-
"@prisma/client": "^6.12.0",
64-
"@prisma/instrumentation": "^6.12.0",
61+
"@prisma/adapter-neon": "^7.0.0",
62+
"@prisma/adapter-pg": "^7.0.0",
63+
"@prisma/client": "^7.0.0",
64+
"@prisma/extension-read-replicas": "^0.5.0",
65+
"@prisma/instrumentation": "^7.0.0",
6566
"@react-email/render": "^1.2.1",
6667
"@sentry/nextjs": "^10.11.0",
6768
"@simplewebauthn/server": "^11.0.0",
@@ -109,7 +110,7 @@
109110
"concurrently": "^8.2.2",
110111
"glob": "^10.4.1",
111112
"import-in-the-middle": "1.14.2",
112-
"prisma": "^6.12.0",
113+
"prisma": "^7.0.0",
113114
"require-in-the-middle": "^7.4.0",
114115
"rimraf": "^5.0.5",
115116
"tsup": "^8.3.0",

apps/backend/prisma.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'dotenv/config'
2+
import { defineConfig, env } from 'prisma/config'
3+
4+
export default defineConfig({
5+
schema: 'prisma/schema.prisma',
6+
migrations: {
7+
path: 'prisma/migrations',
8+
seed: 'pnpm run db-seed-script',
9+
},
10+
datasource: {
11+
url: env('STACK_DATABASE_CONNECTION_STRING'),
12+
},
13+
})
14+

apps/backend/prisma/schema.prisma

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
generator client {
2-
provider = "prisma-client-js"
3-
previewFeatures = ["driverAdapters", "relationJoins"]
2+
provider = "prisma-client"
3+
output = "../src/generated/prisma"
44
}
55

66
datasource db {
7-
provider = "postgresql"
8-
url = env("STACK_DATABASE_CONNECTION_STRING")
9-
directUrl = env("STACK_DIRECT_DATABASE_CONNECTION_STRING")
7+
provider = "postgresql"
108
}
119

1210
model SchemaMigration {

apps/backend/prisma/seed.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import { teamMembershipsCrudHandlers } from '@/app/api/latest/team-memberships/crud';
33
import { teamsCrudHandlers } from '@/app/api/latest/teams/crud';
44
import { usersCrudHandlers } from '@/app/api/latest/users/crud';
5+
import { CustomerType, EmailOutboxCreatedWith, Prisma, PrismaClient, PurchaseCreationSource, SubscriptionStatus } from '@/generated/prisma/client';
56
import { overrideEnvironmentConfigOverride } from '@/lib/config';
67
import { ensurePermissionDefinition, grantTeamPermission } from '@/lib/permissions';
78
import { createOrUpdateProjectWithLegacyConfig, getProject } from '@/lib/projects';
89
import { DEFAULT_BRANCH_ID, getSoleTenancyFromProjectBranch, type Tenancy } from '@/lib/tenancies';
910
import { getPrismaClientForTenancy, globalPrismaClient } from '@/prisma-client';
10-
import { CustomerType, EmailOutboxCreatedWith, Prisma, PrismaClient, PurchaseCreationSource, SubscriptionStatus } from '@prisma/client';
1111
import { ALL_APPS } from '@stackframe/stack-shared/dist/apps/apps-config';
1212
import { DEFAULT_EMAIL_THEME_ID } from '@stackframe/stack-shared/dist/helpers/emails';
1313
import { AdminUserProjectsCrud, ProjectsCrud } from '@stackframe/stack-shared/dist/interface/crud/projects';
@@ -16,7 +16,6 @@ import { throwErr } from '@stackframe/stack-shared/dist/utils/errors';
1616
import { typedEntries, typedFromEntries } from '@stackframe/stack-shared/dist/utils/objects';
1717
import { generateUuid } from '@stackframe/stack-shared/dist/utils/uuids';
1818

19-
const globalPrisma = new PrismaClient();
2019
const DUMMY_PROJECT_ID = '6fbbf22e-f4b2-4c6e-95a1-beab6fa41063';
2120
const EXPLORATORY_TEAM_DISPLAY_NAME = 'Exploratory Research and Insight Partnership With Very Long Collaborative Name For Testing';
2221

@@ -276,7 +275,7 @@ export async function seed() {
276275
superSecretAdminKey: process.env.STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY || throwErr('STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY is not set'),
277276
};
278277

279-
await globalPrisma.apiKeySet.upsert({
278+
await globalPrismaClient.apiKeySet.upsert({
280279
where: { projectId_id: { projectId: 'internal', id: apiKeyId } },
281280
update: {
282281
...keySet,

0 commit comments

Comments
 (0)