210 lines
5.2 KiB
Plaintext
210 lines
5.2 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// Super Admin da plataforma TemFut (acessa admin.localhost)
|
|
model Admin {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
password String
|
|
name String
|
|
role AdminRole @default(ADMIN)
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
enum AdminRole {
|
|
SUPER_ADMIN // Acesso total
|
|
ADMIN // Acesso de leitura
|
|
}
|
|
|
|
|
|
model Group {
|
|
id String @id @default(cuid())
|
|
slug String @unique @default(cuid()) // Para subdomínios (ex: flamengo.temfut.com)
|
|
name String
|
|
logoUrl String?
|
|
primaryColor String @default("#000000")
|
|
secondaryColor String @default("#ffffff")
|
|
createdAt DateTime @default(now())
|
|
email String? @unique
|
|
password String?
|
|
plan Plan @default(FREE)
|
|
planExpiresAt DateTime?
|
|
matches Match[]
|
|
players Player[]
|
|
sponsors Sponsor[]
|
|
arenas Arena[]
|
|
financialEvents FinancialEvent[]
|
|
pixKey String?
|
|
pixName String?
|
|
status GroupStatus @default(ACTIVE)
|
|
showTotalInPublic Boolean @default(true)
|
|
}
|
|
|
|
enum GroupStatus {
|
|
ACTIVE
|
|
FROZEN
|
|
}
|
|
|
|
enum Plan {
|
|
FREE
|
|
BASIC
|
|
PRO
|
|
}
|
|
|
|
model Player {
|
|
id String @id @default(cuid())
|
|
name String
|
|
number Int?
|
|
position String @default("MEI")
|
|
level Int @default(3)
|
|
isLeader Boolean @default(false)
|
|
groupId String
|
|
createdAt DateTime @default(now())
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
teams TeamPlayer[]
|
|
attendances Attendance[]
|
|
payments Payment[]
|
|
|
|
@@unique([number, groupId])
|
|
}
|
|
|
|
model Attendance {
|
|
id String @id @default(cuid())
|
|
playerId String
|
|
player Player @relation(fields: [playerId], references: [id])
|
|
matchId String
|
|
match Match @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
|
status String @default("CONFIRMED") // CONFIRMED, CANCELED
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([playerId, matchId])
|
|
}
|
|
|
|
model Match {
|
|
id String @id @default(cuid())
|
|
date DateTime
|
|
location String?
|
|
arenaId String?
|
|
arena Arena? @relation(fields: [arenaId], references: [id])
|
|
maxPlayers Int?
|
|
drawSeed String?
|
|
status MatchStatus @default(SCHEDULED)
|
|
groupId String
|
|
createdAt DateTime @default(now())
|
|
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
teams Team[]
|
|
attendances Attendance[]
|
|
isRecurring Boolean @default(false)
|
|
recurrenceInterval String? // 'WEEKLY'
|
|
recurrenceEndDate DateTime?
|
|
}
|
|
|
|
model Team {
|
|
id String @id @default(cuid())
|
|
name String
|
|
color String
|
|
matchId String
|
|
match Match @relation(fields: [matchId], references: [id], onDelete: Cascade)
|
|
players TeamPlayer[]
|
|
}
|
|
|
|
model TeamPlayer {
|
|
id String @id @default(cuid())
|
|
teamId String
|
|
playerId String
|
|
player Player @relation(fields: [playerId], references: [id])
|
|
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum MatchStatus {
|
|
SCHEDULED
|
|
IN_PROGRESS
|
|
COMPLETED
|
|
CANCELED
|
|
}
|
|
|
|
model Sponsor {
|
|
id String @id @default(cuid())
|
|
name String
|
|
logoUrl String?
|
|
groupId String
|
|
createdAt DateTime @default(now())
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
}
|
|
|
|
model Arena {
|
|
id String @id @default(cuid())
|
|
name String
|
|
address String?
|
|
groupId String
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
matches Match[]
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model FinancialEvent {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String?
|
|
totalAmount Float? // Meta de arrecadação (opcional)
|
|
pricePerPerson Float? // Valor por pessoa
|
|
dueDate DateTime
|
|
type FinancialEventType @default(MONTHLY_FEE)
|
|
status FinancialEventStatus @default(OPEN)
|
|
|
|
groupId String
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
|
|
payments Payment[]
|
|
createdAt DateTime @default(now())
|
|
|
|
isRecurring Boolean @default(false)
|
|
recurrenceInterval String? // 'MONTHLY', 'WEEKLY'
|
|
recurrenceEndDate DateTime?
|
|
showTotalInPublic Boolean @default(true)
|
|
}
|
|
|
|
model Payment {
|
|
id String @id @default(cuid())
|
|
financialEventId String
|
|
financialEvent FinancialEvent @relation(fields: [financialEventId], references: [id], onDelete: Cascade)
|
|
|
|
playerId String
|
|
player Player @relation(fields: [playerId], references: [id])
|
|
|
|
amount Float
|
|
status PaymentStatus @default(PENDING)
|
|
paidAt DateTime?
|
|
method String? // PIX, CASH
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([financialEventId, playerId])
|
|
}
|
|
|
|
enum FinancialEventType {
|
|
MONTHLY_FEE
|
|
EXTRA_EVENT
|
|
CONTRIBUTION
|
|
}
|
|
|
|
enum FinancialEventStatus {
|
|
OPEN
|
|
CLOSED
|
|
CANCELED
|
|
}
|
|
|
|
enum PaymentStatus {
|
|
PENDING
|
|
PAID
|
|
WAIVED
|
|
}
|