Skip to content

Commit 1a73854

Browse files
Upgrade project to prisma v6 (#568)
Co-authored-by: me <[email protected]> Co-authored-by: Cursor Agent <[email protected]>
1 parent 927e76b commit 1a73854

File tree

14 files changed

+657
-72
lines changed

14 files changed

+657
-72
lines changed

.env.example

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# We try to mock as much as possible so you don't have to have these set to anything real to contribute
2+
23
# We also only use these variables when you're trying to use the APIs that need them (lazy initialization)
4+
35
# If you need to work on the feature that uses the API, it must be set.
46
# If it's mocked in development, then you can set its value to nonsense.
57
# We'll label them by what feature you need them for and whether it's mocked.
68

79
SENTRY_DSN="https://[email protected]/5878963"
10+
811
SENTRY_AUTH_TOKEN=some_token
912
SENTRY_ORG=some_org
1013
SENTRY_PROJECT=some_project
@@ -13,6 +16,7 @@ SENTRY_PROJECT_ID=5878963
1316
# Feature: /contact and /login
1417
# Mocked: yes
1518
# Check the logs which print out the content of every "email" sent for any manual verification you need to do or links you need to open
19+
1620
MAILGUN_SENDING_KEY=key-some-mailgun-key
1721
MAILGUN_DOMAIN=some.domain.com
1822

@@ -27,13 +31,14 @@ TITO_API_SECRET=secret_live_some_long_thing
2731
# Feature: authentication
2832
# Mocked: Unnecessary (any value can be used)
2933
# Technically we have a fallback in development so this doesn't even need to be set
34+
3035
SESSION_SECRET=anything_works_here
3136
MAGIC_LINK_SECRET=whatever_stuff
3237

3338
# Feature: basically everything
3439
# Mocked: No, must run sqlite locally
3540
DATABASE_FILENAME="sqlite.db"
36-
DATABASE_URL="file:./sqlite.db?connection_limit=1"
41+
DATABASE_URL="file:./prisma/sqlite.db"
3742
CACHE_DATABASE_PATH="other/cache.db"
3843
LITEFS_DIR="./prisma"
3944

@@ -91,4 +96,4 @@ REFRESH_CACHE_SECRET=really_whatever
9196
VERIFIER_API_KEY=some_api_key
9297

9398
# Feature: Cloudflare OAuth
94-
CF_INTERNAL_SECRET=some_long_random_string
99+
CF_INTERNAL_SECRET=some_long_random_string

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_modules/
1010
tsconfig.tsbuildinfo
1111
/prisma/sqlite.db
1212
/prisma/sqlite.db-journal
13+
/app/utils/prisma-generated.server
1314

1415
other/postcss.ignored
1516

app/routes/resources+/webauthn+/verify-registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function action({ request }: ActionFunctionArgs) {
8989
data: {
9090
id: credential.id,
9191
aaguid,
92-
publicKey: Buffer.from(credential.publicKey),
92+
publicKey: new Uint8Array(credential.publicKey),
9393
userId: user.id,
9494
webauthnUserId,
9595
counter: credential.counter,

app/utils/prisma.server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { remember } from '@epic-web/remember'
2-
import { PrismaClient } from '@prisma/client'
2+
import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3'
33
import chalk from 'chalk'
44
import pProps from 'p-props'
55
import { type Session } from '#app/types.ts'
66
import { ensurePrimary } from '#app/utils/litefs-js.server.ts'
77
import { decrypt, encrypt } from './encryption.server.ts'
8+
import { PrismaClient } from './prisma-generated.server/client.ts'
89
import { time, type Timings } from './timing.server.ts'
910

1011
const logThreshold = 500
@@ -15,7 +16,14 @@ function getClient(): PrismaClient {
1516
// NOTE: during development if you change anything in this function, remember
1617
// that this only runs once per server restart and won't automatically be
1718
// re-run per request like everything else is.
19+
const url = process.env.DATABASE_URL
20+
if (!url) {
21+
throw new Error(
22+
'DATABASE_URL is required (expected a file: URL for SQLite).',
23+
)
24+
}
1825
const client = new PrismaClient({
26+
adapter: new PrismaBetterSQLite3({ url }),
1927
log: [
2028
{ level: 'query', emit: 'event' },
2129
{ level: 'error', emit: 'stdout' },

app/utils/session.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { type User } from '@prisma/client'
21
import { createCookieSessionStorage, redirect } from '@remix-run/node'
32
import { z } from 'zod'
43
import { ensurePrimary } from '#app/utils/litefs-js.server.ts'
4+
import { type User } from '#app/utils/prisma-generated.server/client.ts'
55
import { getLoginInfoSession } from './login.server.ts'
66
import { getRequiredServerEnvVar } from './misc.tsx'
77
import {

e2e/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import path from 'path'
22
import { test as base } from '@playwright/test'
3-
import { PrismaClient, type User } from '@prisma/client'
43
import { parse } from 'cookie'
54
import fsExtra from 'fs-extra'
65
import invariant from 'tiny-invariant'
6+
import {
7+
PrismaClient,
8+
type User,
9+
} from '#app/utils/prisma-generated.server/client.ts'
710
import '../app/entry.server.tsx'
811
import { getSession } from '../app/utils/session.server.ts'
912
import { createUser } from '../prisma/seed-utils.ts'

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { config as defaultConfig } from '@epic-web/config/eslint'
33
/** @type {import("eslint").Linter.Config[]} */
44
export default [
55
{
6-
ignores: ['./oauth'],
6+
ignores: ['./oauth', './app/utils/prisma-generated.server'],
77
},
88
...defaultConfig,
99
]

0 commit comments

Comments
 (0)