feat: Initialize NestJS backend project with Prisma, core modules, configuration, and common utilities.
This commit is contained in:
147
prisma/schema.prisma
Normal file
147
prisma/schema.prisma
Normal file
@@ -0,0 +1,147 @@
|
||||
// Real Estate Agent Platform - Database Schema
|
||||
// Milestone 1: Foundation & Authentication
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// ENUMS
|
||||
// ===========================================
|
||||
|
||||
enum UserRole {
|
||||
USER
|
||||
AGENT
|
||||
ADMIN
|
||||
}
|
||||
|
||||
enum UserStatus {
|
||||
ACTIVE
|
||||
INACTIVE
|
||||
SUSPENDED
|
||||
PENDING_VERIFICATION
|
||||
}
|
||||
|
||||
enum AuthProvider {
|
||||
LOCAL
|
||||
GOOGLE
|
||||
FACEBOOK
|
||||
}
|
||||
|
||||
enum VerificationStatus {
|
||||
PENDING
|
||||
APPROVED
|
||||
REJECTED
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// USER & AUTHENTICATION (Milestone 1)
|
||||
// ===========================================
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String? // Null for social login users
|
||||
firstName String?
|
||||
lastName String?
|
||||
phone String?
|
||||
avatar String?
|
||||
role UserRole @default(USER)
|
||||
status UserStatus @default(ACTIVE)
|
||||
emailVerified Boolean @default(false)
|
||||
emailVerifiedAt DateTime?
|
||||
|
||||
// Social Auth
|
||||
authProvider AuthProvider @default(LOCAL)
|
||||
googleId String? @unique
|
||||
facebookId String? @unique
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lastLoginAt DateTime?
|
||||
|
||||
// Relations (will be added in later milestones)
|
||||
agentProfile AgentProfile?
|
||||
sessions Session[]
|
||||
passwordResets PasswordReset[]
|
||||
|
||||
@@index([email])
|
||||
@@index([role])
|
||||
@@index([status])
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
token String @unique
|
||||
refreshToken String? @unique
|
||||
userAgent String?
|
||||
ipAddress String?
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@index([token])
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model PasswordReset {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
usedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([token])
|
||||
@@map("password_resets")
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// AGENT PROFILE (Milestone 2 - Placeholder)
|
||||
// ===========================================
|
||||
|
||||
model AgentProfile {
|
||||
id String @id @default(uuid())
|
||||
userId String @unique
|
||||
slug String @unique
|
||||
bio String?
|
||||
headline String?
|
||||
location String?
|
||||
city String?
|
||||
state String?
|
||||
country String?
|
||||
yearsOfExperience Int?
|
||||
licenseNumber String?
|
||||
|
||||
// Verification
|
||||
verificationStatus VerificationStatus @default(PENDING)
|
||||
verifiedAt DateTime?
|
||||
|
||||
// Profile completeness
|
||||
isProfileComplete Boolean @default(false)
|
||||
profileCompleteness Int @default(0)
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([slug])
|
||||
@@index([verificationStatus])
|
||||
@@index([city, state])
|
||||
@@map("agent_profiles")
|
||||
}
|
||||
Reference in New Issue
Block a user