Last active
July 13, 2025 10:11
-
-
Save hf35/43915b93c784d2fec768fcc3a22b588b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generator client { | |
| provider = "prisma-client-js" | |
| } | |
| datasource db { | |
| provider = "postgresql" | |
| url = env("DATABASE_URL") | |
| } | |
| // ========== Main User model compatible with NextAuth ========== | |
| model User { | |
| id String @id @default(cuid()) | |
| email String? @unique | |
| emailVerified DateTime? | |
| hashedPassword String? // used for email/password login | |
| name String? | |
| image String? | |
| role UserRole @default(CUSTOMER) // user role: CUSTOMER or ADMIN | |
| // relations | |
| accounts Account[] | |
| sessions Session[] | |
| profile UserProfile? | |
| balance UserBalance? | |
| createdAt DateTime @default(now()) | |
| updatedAt DateTime @updatedAt | |
| } | |
| // ========== OAuth provider accounts ========== | |
| model Account { | |
| id String @id @default(cuid()) | |
| userId String | |
| type String | |
| provider String | |
| providerAccountId String | |
| refresh_token String? | |
| access_token String? | |
| expires_at Int? | |
| token_type String? | |
| scope String? | |
| id_token String? | |
| session_state String? | |
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | |
| @@unique([provider, providerAccountId]) | |
| } | |
| // ========== NextAuth sessions ========== | |
| model Session { | |
| id String @id @default(cuid()) | |
| sessionToken String @unique | |
| userId String | |
| expires DateTime | |
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | |
| } | |
| // ========== Extended user profile ========== | |
| model UserProfile { | |
| id String @id @default(cuid()) | |
| userId String @unique | |
| firstName String? | |
| lastName String? | |
| birthDate DateTime? | |
| country String? | |
| state String? | |
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | |
| } | |
| // ========== User balances: SC and GC ========== | |
| model UserBalance { | |
| id String @id @default(cuid()) | |
| userId String @unique | |
| sc Int @default(0) | |
| gc Int @default(0) | |
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | |
| } | |
| // ========== Enum for user roles ========== | |
| enum UserRole { | |
| ADMIN | |
| CUSTOMER | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment