- Add Project, ProjectMember, ProjectInvite models to Prisma schema - Add API routes for projects CRUD, members management, invite links - Add ProjectSelector and ProjectSettings components - Add /projects, /projects/[id]/settings, /invite/[token] pages - Update Navbar with navigation links
146 lines
3.7 KiB
Plaintext
146 lines
3.7 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
directUrl = env("DIRECT_URL")
|
|
}
|
|
|
|
// ==================== AUTH MODELS ====================
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
email String @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
password String? // null if using OAuth
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
tasks Task[]
|
|
ownedProjects Project[] @relation("OwnedProjects")
|
|
projectMembers ProjectMember[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
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])
|
|
@@map("accounts")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("sessions")
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
@@map("verification_tokens")
|
|
}
|
|
|
|
// ==================== TASK MODEL ====================
|
|
|
|
model Task {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
projectId String? // Optional - cho backward compatibility
|
|
title String
|
|
description String?
|
|
status String @default("TODO") // TODO, IN_PROGRESS, DONE
|
|
deadline DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
@@index([projectId])
|
|
@@index([status])
|
|
@@index([deadline])
|
|
@@map("tasks")
|
|
}
|
|
|
|
// ==================== PROJECT MODELS ====================
|
|
|
|
model Project {
|
|
id String @id @default(cuid())
|
|
name String
|
|
description String?
|
|
ownerId String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
owner User @relation("OwnedProjects", fields: [ownerId], references: [id], onDelete: Cascade)
|
|
members ProjectMember[]
|
|
invites ProjectInvite[]
|
|
tasks Task[]
|
|
|
|
@@index([ownerId])
|
|
@@map("projects")
|
|
}
|
|
|
|
model ProjectMember {
|
|
id String @id @default(cuid())
|
|
projectId String
|
|
userId String
|
|
role String @default("MEMBER") // OWNER, ADMIN, MEMBER
|
|
joinedAt DateTime @default(now())
|
|
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([projectId, userId])
|
|
@@index([userId])
|
|
@@map("project_members")
|
|
}
|
|
|
|
model ProjectInvite {
|
|
id String @id @default(cuid())
|
|
projectId String
|
|
token String @unique @default(cuid())
|
|
email String?
|
|
expiresAt DateTime
|
|
used Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([token])
|
|
@@index([projectId])
|
|
@@map("project_invites")
|
|
}
|