feat: set up prisma db
This commit is contained in:
parent
f8a84489ad
commit
03c74c47d9
7 changed files with 92 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
DATABASE_URL=
|
||||
DATABASE_URL="file:./dev.db"
|
||||
|
||||
AUTH_SECRET= # Added by `npx auth`. Read more: https://cli.authjs.dev
|
||||
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -40,3 +40,6 @@ yarn-error.log*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# database
|
||||
/prisma/dev.db
|
12
package.json
12
package.json
|
@ -7,14 +7,21 @@
|
|||
"build": "prettier --check . && next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"format": "prettier --write ."
|
||||
"format": "prettier --write .",
|
||||
"prisma:migrate": "dotenv -e .env.local -- prisma migrate dev",
|
||||
"prisma:generate": "dotenv -e .env.local -- prisma generate",
|
||||
"prisma:studio": "dotenv -e .env.local -- prisma studio",
|
||||
"prisma:db:push": "dotenv -e .env.local -- prisma db push",
|
||||
"prisma:migrate:reset": "dotenv -e .env.local -- prisma migrate reset"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/prisma-adapter": "^2.9.1",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
||||
"@prisma/client": "^6.7.0",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.14",
|
||||
"@radix-ui/react-hover-card": "^1.1.13",
|
||||
"@radix-ui/react-label": "^2.1.6",
|
||||
|
@ -40,12 +47,13 @@
|
|||
"@types/node": "22.15.18",
|
||||
"@types/react": "19.1.4",
|
||||
"@types/react-dom": "19.1.5",
|
||||
"dotenv-cli": "^8.0.0",
|
||||
"eslint": "9.26.0",
|
||||
"eslint-config-next": "15.3.2",
|
||||
"eslint-config-prettier": "10.1.5",
|
||||
"postcss": "8.5.3",
|
||||
"prettier": "3.5.3",
|
||||
"prisma": "6.7.0",
|
||||
"prisma": "^6.7.0",
|
||||
"tailwindcss": "4.1.6",
|
||||
"tw-animate-css": "1.2.9",
|
||||
"typescript": "5.8.3"
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/prisma"
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum participant_status {
|
||||
|
@ -102,12 +102,12 @@ model Account {
|
|||
type String
|
||||
provider String
|
||||
providerAccountId String @map("provider_account_id")
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
refresh_token String?
|
||||
access_token String?
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
id_token String?
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
|
|
@ -5,6 +5,9 @@ import Credentials from 'next-auth/providers/credentials';
|
|||
|
||||
import Authentik from 'next-auth/providers/authentik';
|
||||
|
||||
import { PrismaAdapter } from '@auth/prisma-adapter';
|
||||
import { prisma } from '@/prisma';
|
||||
|
||||
const providers: Provider[] = [
|
||||
!process.env.DISABLE_PASSWORD_LOGIN &&
|
||||
Credentials({
|
||||
|
@ -33,7 +36,8 @@ export const providerMap = providers
|
|||
.filter((provider) => provider.id !== 'credentials');
|
||||
|
||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
providers,
|
||||
providers: [],
|
||||
adapter: PrismaAdapter(prisma),
|
||||
session: {
|
||||
strategy: 'jwt',
|
||||
},
|
||||
|
|
7
src/prisma.ts
Normal file
7
src/prisma.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { PrismaClient } from "@prisma/client"
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }
|
||||
|
||||
export const prisma = globalForPrisma.prisma || new PrismaClient()
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma
|
61
yarn.lock
61
yarn.lock
|
@ -46,6 +46,17 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@auth/prisma-adapter@npm:^2.9.1":
|
||||
version: 2.9.1
|
||||
resolution: "@auth/prisma-adapter@npm:2.9.1"
|
||||
dependencies:
|
||||
"@auth/core": "npm:0.39.1"
|
||||
peerDependencies:
|
||||
"@prisma/client": ">=2.26.0 || >=3 || >=4 || >=5 || >=6"
|
||||
checksum: 10c0/615ee7c02f690e35ccac8206607a4345ca6455c322a741ddd4dbd52e7a068ace9e5c46c4d8a50fe471ca2c2fb6a5b4bb9924cbd2e911613f671fe929c33278d4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@emnapi/core@npm:^1.4.0, @emnapi/core@npm:^1.4.3":
|
||||
version: 1.4.3
|
||||
resolution: "@emnapi/core@npm:1.4.3"
|
||||
|
@ -884,6 +895,21 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@prisma/client@npm:^6.7.0":
|
||||
version: 6.7.0
|
||||
resolution: "@prisma/client@npm:6.7.0"
|
||||
peerDependencies:
|
||||
prisma: "*"
|
||||
typescript: ">=5.1.0"
|
||||
peerDependenciesMeta:
|
||||
prisma:
|
||||
optional: true
|
||||
typescript:
|
||||
optional: true
|
||||
checksum: 10c0/863a8085800c8ada3247bc8b3f8a7056e341045f7f6fd73c7cd133b91298c8603f783869e5a7357d62394fa2ddac8c09ee27d7325bbb803a870edca5b914d33f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@prisma/config@npm:6.7.0":
|
||||
version: 6.7.0
|
||||
resolution: "@prisma/config@npm:6.7.0"
|
||||
|
@ -2749,6 +2775,34 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dotenv-cli@npm:^8.0.0":
|
||||
version: 8.0.0
|
||||
resolution: "dotenv-cli@npm:8.0.0"
|
||||
dependencies:
|
||||
cross-spawn: "npm:^7.0.6"
|
||||
dotenv: "npm:^16.3.0"
|
||||
dotenv-expand: "npm:^10.0.0"
|
||||
minimist: "npm:^1.2.6"
|
||||
bin:
|
||||
dotenv: cli.js
|
||||
checksum: 10c0/000469632758b7b44aaaa80cbbbd7f0c94dc170ec02e51aa8d8280341a0108fb7407954c23054257b77235b064033efdb8745836633eb6fd1586924953cf0528
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dotenv-expand@npm:^10.0.0":
|
||||
version: 10.0.0
|
||||
resolution: "dotenv-expand@npm:10.0.0"
|
||||
checksum: 10c0/298f5018e29cfdcb0b5f463ba8e8627749103fbcf6cf81c561119115754ed582deee37b49dfc7253028aaba875ab7aea5fa90e5dac88e511d009ab0e6677924e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dotenv@npm:^16.3.0":
|
||||
version: 16.5.0
|
||||
resolution: "dotenv@npm:16.5.0"
|
||||
checksum: 10c0/5bc94c919fbd955bf0ba44d33922a1e93d1078e64a1db5c30faeded1d996e7a83c55332cb8ea4fae5a9ca4d0be44cbceb95c5811e70f9f095298df09d1997dd9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dunder-proto@npm:^1.0.0, dunder-proto@npm:^1.0.1":
|
||||
version: 1.0.1
|
||||
resolution: "dunder-proto@npm:1.0.1"
|
||||
|
@ -4580,12 +4634,14 @@ __metadata:
|
|||
version: 0.0.0-use.local
|
||||
resolution: "meetup@workspace:."
|
||||
dependencies:
|
||||
"@auth/prisma-adapter": "npm:^2.9.1"
|
||||
"@eslint/eslintrc": "npm:3.3.1"
|
||||
"@fortawesome/fontawesome-svg-core": "npm:^6.7.2"
|
||||
"@fortawesome/free-brands-svg-icons": "npm:^6.7.2"
|
||||
"@fortawesome/free-regular-svg-icons": "npm:^6.7.2"
|
||||
"@fortawesome/free-solid-svg-icons": "npm:^6.7.2"
|
||||
"@fortawesome/react-fontawesome": "npm:^0.2.2"
|
||||
"@prisma/client": "npm:^6.7.0"
|
||||
"@radix-ui/react-dropdown-menu": "npm:^2.1.14"
|
||||
"@radix-ui/react-hover-card": "npm:^1.1.13"
|
||||
"@radix-ui/react-label": "npm:^2.1.6"
|
||||
|
@ -4601,6 +4657,7 @@ __metadata:
|
|||
"@types/react-dom": "npm:19.1.5"
|
||||
class-variance-authority: "npm:^0.7.1"
|
||||
clsx: "npm:^2.1.1"
|
||||
dotenv-cli: "npm:^8.0.0"
|
||||
eslint: "npm:9.26.0"
|
||||
eslint-config-next: "npm:15.3.2"
|
||||
eslint-config-prettier: "npm:10.1.5"
|
||||
|
@ -4610,7 +4667,7 @@ __metadata:
|
|||
next-themes: "npm:^0.4.6"
|
||||
postcss: "npm:8.5.3"
|
||||
prettier: "npm:3.5.3"
|
||||
prisma: "npm:6.7.0"
|
||||
prisma: "npm:^6.7.0"
|
||||
react: "npm:^19.0.0"
|
||||
react-dom: "npm:^19.0.0"
|
||||
tailwind-merge: "npm:^3.2.0"
|
||||
|
@ -5240,7 +5297,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prisma@npm:6.7.0":
|
||||
"prisma@npm:^6.7.0":
|
||||
version: 6.7.0
|
||||
resolution: "prisma@npm:6.7.0"
|
||||
dependencies:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue