Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions solid-start/with-prisma/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copy this file and name the copy `.env`
# You can update this field below to point to a SQLite database file at a different path
DATABASE_URL=file:./prisma/dev.db
1 change: 1 addition & 0 deletions solid-start/with-prisma/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
.output/
dist/
.nitro/
generated
6 changes: 4 additions & 2 deletions solid-start/with-prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"preview": "vite preview"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.13",
"@types/node": "^24.7.0"
},
"dependencies": {
"@prisma/client": "^5.12.1",
"@prisma/adapter-better-sqlite3": "^7.5.0",
"@prisma/client": "^7.5.0",
"@solidjs/router": "^0.15.0",
"@solidjs/start": "2.0.0-alpha.2",
"prisma": "^5.12.1",
"prisma": "^7.5.0",
"solid-js": "^1.9.5",
"vite": "^7.0.0",
"@solidjs/vite-plugin-nitro-2": "^0.1.0"
Expand Down
815 changes: 768 additions & 47 deletions solid-start/with-prisma/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions solid-start/with-prisma/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
onlyBuiltDependencies:
- better-sqlite3
33 changes: 33 additions & 0 deletions solid-start/with-prisma/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { readFileSync } from "fs"
import { parseEnv, styleText } from "node:util"
import { defineConfig } from "prisma/config"

let { DATABASE_URL } = process.env
let readDotEnvError: unknown

if (!DATABASE_URL) {
try {
({ DATABASE_URL } = parseEnv(readFileSync(`.env`, { encoding: `utf8` })))
} catch (error) {
readDotEnvError = error
}
}

export default defineConfig({
datasource: {
// We do this in a getter because this field is not always read
get url() {
if (DATABASE_URL)
return DATABASE_URL

console.error(styleText(`red`, `Environment variable DATABASE_URL must be set`))

if (readDotEnvError) {
console.error(`Got error reading .env:`)
console.error(readDotEnvError)
}

process.exit(1)
}
}
})
4 changes: 2 additions & 2 deletions solid-start/with-prisma/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
provider = "prisma-client"
output = "../generated/prisma"
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}

model User {
Expand Down
7 changes: 5 additions & 2 deletions solid-start/with-prisma/src/lib/db.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import { PrismaClient } from "@prisma/client";
export const db = new PrismaClient();
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import { PrismaClient } from "../../generated/prisma/client";
import config from "../../prisma.config";

export const db = new PrismaClient({ adapter: new PrismaBetterSqlite3({ url: config.datasource!.url! }) });