From 0465612ab171b1691256d44240b9287ecff0c7a8 Mon Sep 17 00:00:00 2001 From: Jowo Date: Sun, 20 Oct 2024 19:03:53 +0100 Subject: [PATCH] fixing schema and updating readme --- examples/prisma/.gitignore | 3 ++ examples/prisma/README.md | 2 ++ examples/prisma/package.json | 2 +- examples/prisma/prisma/schema.prisma | 54 ++++++++++++++-------------- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/examples/prisma/.gitignore b/examples/prisma/.gitignore index d35894a..2434996 100644 --- a/examples/prisma/.gitignore +++ b/examples/prisma/.gitignore @@ -36,3 +36,6 @@ next-env.d.ts # env .env + +# prisma +prisma/migrations/** \ No newline at end of file diff --git a/examples/prisma/README.md b/examples/prisma/README.md index db30b82..8c8fb3e 100644 --- a/examples/prisma/README.md +++ b/examples/prisma/README.md @@ -18,4 +18,6 @@ Along side the `.env.example` file in this example app, create a `.env` file wit Run `npm i` to install dependencies. +Run `npm run db:generate` and `npm run db:migrate` + Run `npm run dev` to launch the dev server and visit `localhost:3000` to view the app. diff --git a/examples/prisma/package.json b/examples/prisma/package.json index 4031d17..12e0e50 100644 --- a/examples/prisma/package.json +++ b/examples/prisma/package.json @@ -9,7 +9,7 @@ "lint": "next lint", "db:init": "prisma init", "db:generate": "prisma generate", - "db:migrate": "prisma migrate dev --name init" + "db:migrate": "prisma migrate dev" }, "dependencies": { "@next-auth/prisma-adapter": "^1.0.7", diff --git a/examples/prisma/prisma/schema.prisma b/examples/prisma/prisma/schema.prisma index a457107..750da55 100644 --- a/examples/prisma/prisma/schema.prisma +++ b/examples/prisma/prisma/schema.prisma @@ -19,51 +19,53 @@ model Pubkey { } model Account { - id String @id @default(cuid()) - userId String - providerType String - providerId String - providerAccountId String - refreshToken String? - accessToken String? - accessTokenExpires DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id]) + id String @id @default(cuid()) + userId String @map("user_id") + type String + provider String + providerAccountId String @map("provider_account_id") + refresh_token String? @db.Text + access_token String? @db.Text + expires_at Int? + token_type String? + scope String? + id_token String? @db.Text + session_state String? + success Boolean? - @@unique([providerId, providerAccountId]) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@unique([provider, providerAccountId]) + @@map("accounts") } model Session { id String @id @default(cuid()) - userId String + sessionToken String @unique @map("session_token") + userId String @map("user_id") expires DateTime - sessionToken String @unique - accessToken String @unique - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id]) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@map("sessions") } model User { id String @id @default(cuid()) name String? email String? @unique - emailVerified DateTime? + emailVerified DateTime? @map("email_verified") image String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt accounts Account[] sessions Session[] + + @@map("users") } -model VerificationRequest { - id String @id @default(cuid()) +model VerificationToken { identifier String - token String @unique + token String expires DateTime - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt @@unique([identifier, token]) + @@map("verification_tokens") } \ No newline at end of file