generator client { provider = "prisma-client" output = "../src/generated/prisma" engineType = "client" } datasource db { provider = "postgresql" } model Community { id String @id @unique @default(uuid()) name String @unique description String? avatar String? creationDate DateTime @default(now()) User User @relation(name: "OwnerCommunityToUser", fields: [ownerId], references: [id]) ownerId String members User[] @relation(name: "MembersCommunitiesToUsers") channels Channel[] roles Role[] invites Invite[] attachments Attachment[] chunks Chunk[] } model Channel { id String @id @unique @default(uuid()) name String description String? category String? order Int? @default(autoincrement()) community Community @relation(fields: [communityId], references: [id], onDelete: Cascade) communityId String messages Message[] creationDate DateTime @default(now()) } model Role { id String @id @unique @default(uuid()) name String description String? color String? order Int? @default(autoincrement()) showInMembers Boolean? community Community @relation(fields: [communityId], references: [id], onDelete: Cascade) communityId String users User[] @relation(name: "UsersRolesToUsers") permissions String[] creationDate DateTime @default(now()) } model User { id String @id @unique @default(uuid()) username String @unique nickname String? email String? @unique passwordHash String? description String? avatar String? admin Boolean @default(false) registerDate DateTime @default(now()) lastLogin DateTime? Session Session[] ownedInvites Invite[] ownedCommunities Community[] @relation(name: "OwnerCommunityToUser") communities Community[] @relation(name: "MembersCommunitiesToUsers") roles Role[] @relation(name: "UsersRolesToUsers") messages Message[] reactions Reaction[] } model Session { id String @id @unique @default(uuid()) name String? userAgent String? owner User @relation(fields: [userId], references: [id], onDelete: Cascade) userId String cookie String storageSecret String? creationDate DateTime @default(now()) refreshDate DateTime @default(now()) } model Invite { id String @id @unique @default(uuid()) Community Community @relation(fields: [communityId], references: [id], onDelete: Cascade) communityId String User User @relation(fields: [creatorId], references: [id], onDelete: Cascade) creatorId String totalInvites Int @default(0) remainingInvites Int @default(0) creationDate DateTime @default(now()) expirationDate DateTime? } model Message { id String @id @unique @default(uuid()) text String iv String? replyToId String? edited Boolean @default(false) editHistory String[] @default([]) reactions Reaction[] attachments Attachment[] owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade) ownerId String channel Channel @relation(fields: [channelId], references: [id], onDelete: Cascade) channelId String creationDate DateTime @default(now()) } model Reaction { id String @id @unique @default(uuid()) users User[] content String message Message @relation(fields: [messageId], references: [id], onDelete: Cascade) messageId String } model Attachment { id String @id @unique @default(uuid()) iv String? filename String mimetype String size BigInt chunks Chunk[] finishedUploading Boolean message Message? @relation(fields: [messageId], references: [id], onDelete: Cascade) messageId String? community Community @relation(fields: [communityId], references: [id], onDelete: Cascade) communityId String creationDate DateTime @default(now()) } model Chunk { id String @id @unique @default(uuid()) iv Bytes index Int attachment Attachment @relation(fields: [attachmentId], references: [id], onDelete: Cascade) attachmentId String community Community @relation(fields: [communityId], references: [id], onDelete: Cascade) communityId String }