unreal-chat/apps/api/prisma/schema.prisma
Juan Sebastian Montoya d29d116214 feat: enhance authentication and user management with token-based system
- Implemented robust token-based authentication with access and refresh tokens
- Added JWT token generation, verification, and rotation mechanisms
- Created services for token management, Memcached, and MinIO storage
- Enhanced user registration and login with device-specific tokens
- Added support for profile picture upload and management via MinIO
- Implemented secure password hashing with crypto
- Updated Prisma schema to support refresh tokens and profile picture storage
- Added GraphQL mutations for logout, token refresh, and profile picture handling
- Integrated environment configuration with Zod validation
- Improved error handling and authentication middleware
2025-03-09 22:34:57 -05:00

64 lines
2 KiB
Text

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
email String @unique
username String @unique
password String @db.Text
s3ProfilePicObjectKey String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
messages Message[]
rooms Room[] @relation("RoomMembers")
ownedRooms Room[] @relation("RoomOwner")
refreshTokens RefreshToken[]
}
model Room {
id String @id @default(uuid())
name String
description String?
isPrivate Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
messages Message[]
members User[] @relation("RoomMembers")
ownerId String
owner User @relation("RoomOwner", fields: [ownerId], references: [id])
}
model Message {
id String @id @default(uuid())
content String @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
user User @relation(fields: [userId], references: [id])
roomId String
room Room @relation(fields: [roomId], references: [id])
}
model RefreshToken {
id String @id @default(uuid())
jti String @unique
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
deviceId String
hash String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}