This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
api/prisma/schema.prisma
2022-02-19 19:08:25 +00:00

106 lines
3.6 KiB
Plaintext

datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
name String @unique @db.VarChar(30)
email String? @unique @db.VarChar(254)
password String? @db.Text
logo String? @db.Text
status String? @db.VarChar(50)
biography String? @db.VarChar(160)
website String? @db.VarChar(255)
isConfirmed Boolean @default(false)
temporaryToken String?
temporaryExpirationToken DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
settings UserSetting?
refreshTokens RefreshToken[]
oauths OAuth[]
members Member[]
}
model UserSetting {
id Int @id @default(autoincrement())
language String @default("en") @db.VarChar(10)
theme String @default("dark") @db.VarChar(10)
isPublicEmail Boolean @default(false)
isPublicGuilds Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId Int @unique
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model RefreshToken {
id Int @id @default(autoincrement())
token String @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId Int
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model OAuth {
id Int @id @default(autoincrement())
providerId String @db.Text
provider String @db.VarChar(20)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId Int
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Member {
id Int @id @default(autoincrement())
isOwner Boolean @default(false)
Message Message[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId Int
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
guildId Int
guild Guild? @relation(fields: [guildId], references: [id], onDelete: Cascade)
}
model Guild {
id Int @id @default(autoincrement())
name String @db.VarChar(30)
icon String? @db.Text
description String? @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
members Member[]
channels Channel[]
}
model Channel {
id Int @id @default(autoincrement())
name String @db.VarChar(20)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
guildId Int
guild Guild? @relation(fields: [guildId], references: [id], onDelete: Cascade)
messages Message[]
}
model Message {
id Int @id @default(autoincrement())
value String @db.Text
type String @default("text") @db.VarChar(10)
mimetype String @default("text/plain") @db.VarChar(127)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
memberId Int
member Member? @relation(fields: [memberId], references: [id], onDelete: Cascade)
channelId Int
channel Channel? @relation(fields: [channelId], references: [id], onDelete: Cascade)
}