118 lines
2.8 KiB
Plaintext
118 lines
2.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
passwordHash String?
|
|
name String?
|
|
credits Int @default(0)
|
|
lastCreditAt DateTime @default(now())
|
|
emailVerified DateTime?
|
|
votes Vote[]
|
|
finalVotes FinalVote[]
|
|
proposals Proposal[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// NextAuth fields
|
|
accounts Account[]
|
|
sessions Session[]
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|
|
|
|
model Proposal {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String @db.Text
|
|
authorId String
|
|
author User @relation(fields: [authorId], references: [id])
|
|
status ProposalStatus @default(RANKING)
|
|
score Int @default(0)
|
|
votes Vote[]
|
|
finalVotes FinalVote[]
|
|
votingEndsAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
enum ProposalStatus {
|
|
RANKING
|
|
VOTING
|
|
PASSED
|
|
FAILED
|
|
ARCHIVED
|
|
}
|
|
|
|
model Vote {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
proposalId String
|
|
proposal Proposal @relation(fields: [proposalId], references: [id], onDelete: Cascade)
|
|
weight Int
|
|
creditCost Int
|
|
createdAt DateTime @default(now())
|
|
decaysAt DateTime
|
|
|
|
@@unique([userId, proposalId])
|
|
}
|
|
|
|
model FinalVote {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
proposalId String
|
|
proposal Proposal @relation(fields: [proposalId], references: [id], onDelete: Cascade)
|
|
vote VoteChoice
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([userId, proposalId])
|
|
}
|
|
|
|
enum VoteChoice {
|
|
YES
|
|
NO
|
|
ABSTAIN
|
|
}
|