Skip to content

Commit 6718017

Browse files
authored
chore: upgrade to prisma 7 (#521)
## Changes - the `url` param is no longer supported (https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7#prisma-config-is-now-used-to-configure-the-prisma-cli) so have to swap it to the config instead. take note that you might have to update your `prisma-ls` version so that the typings are correct - patch `prisma-extension-kysely`; we needed this patch because they were importing `Prisma` from `@prisma/client`, which got removed in v7. this was patched to `@prisma/client/extension` which is the correct path. ## Tests - these changes affect mainly **prisma-cli**. as such, i ran all the available commands on `packages/db` to verify that they were working.
1 parent 58159b9 commit 6718017

File tree

7 files changed

+456
-171
lines changed

7 files changed

+456
-171
lines changed

apps/web/src/server/modules/auth/auth.service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,19 @@ export const emailVerifyOtp = async ({
119119
.deleteFrom('VerificationToken')
120120
.where('identifier', '=', vfnIdentifier)
121121
.returningAll()
122-
.executeTakeFirstOrThrow()
122+
.executeTakeFirstOrThrow(
123+
// NOTE: If we are unable to find the token,
124+
// this means that it has been deleted between
125+
// our initial query and the deletion here
126+
() =>
127+
new TRPCError({
128+
code: 'BAD_REQUEST',
129+
message:
130+
'Token is invalid or has expired. Please request a new OTP.',
131+
}),
132+
)
123133
} catch (error) {
124-
// see error code here: https://www.prisma.io/docs/reference/api-reference/error-reference#p2025
134+
// see error code here: https://www.prisma.io/docs/orm/reference/error-reference#p2025
125135
if (
126136
error instanceof Prisma.PrismaClientKnownRequestError &&
127137
error.code === 'P2025'

packages/db/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"prettier": "catalog:",
5858
"prisma": "catalog:prisma",
5959
"prisma-kysely": "catalog:",
60-
"prisma-zod-generator": "^1.32.1",
60+
"prisma-zod-generator": "^2.1.2",
6161
"typescript": "catalog:"
6262
},
6363
"prettier": "@acme/prettier-config"

packages/db/prisma.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { defineConfig } from 'prisma/config'
1+
import { defineConfig, env } from 'prisma/config'
22

33
export default defineConfig({
44
migrations: {
55
seed: 'pnpm dlx tsx prisma/seed.ts',
66
},
7+
datasource: {
8+
url: env('DATABASE_URL'),
9+
},
10+
schema: 'prisma/schema.prisma',
711
})

packages/db/prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
datasource db {
55
provider = "postgresql"
6-
url = env("DATABASE_URL")
76
}
87

98
generator client {

patches/[email protected]

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/dist/cjs/index.js b/dist/cjs/index.js
2+
index ab08b5d36b43ea10a2b3c5e480b2e9af2c12929c..412e6c0ca3154299b7e41ab9c847f9164d1bfe4e 100644
3+
--- a/dist/cjs/index.js
4+
+++ b/dist/cjs/index.js
5+
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6+
};
7+
Object.defineProperty(exports, "__esModule", { value: true });
8+
exports.PrismaKyselyExtensionError = void 0;
9+
-const client_1 = require("@prisma/client");
10+
+const client_1 = require("@prisma/client/extension");
11+
const driver_js_1 = require("./driver.js");
12+
class PrismaKyselyExtensionError extends Error {
13+
constructor(message) {
14+
diff --git a/dist/esm/index.js b/dist/esm/index.js
15+
index bead5527355754c7e33104311d39ae6261acf781..e90737404674470197a83334926cdc92d1bfdbd5 100644
16+
--- a/dist/esm/index.js
17+
+++ b/dist/esm/index.js
18+
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19+
step((generator = generator.apply(thisArg, _arguments || [])).next());
20+
});
21+
};
22+
-import { Prisma } from "@prisma/client";
23+
+import { Prisma } from "@prisma/client/extension";
24+
import { PrismaDriver } from "./driver.js";
25+
export class PrismaKyselyExtensionError extends Error {
26+
constructor(message) {

0 commit comments

Comments
 (0)