Update docs; Add invites to db

This commit is contained in:
Aslan 2025-12-24 13:09:33 +01:00
parent 4f08e4d57f
commit 2fc0f9c404
4 changed files with 70 additions and 34 deletions

View file

@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "Invite" (
"id" TEXT NOT NULL,
"communityId" TEXT,
"totalInvites" INTEGER NOT NULL DEFAULT 0,
"remainingInvites" INTEGER NOT NULL DEFAULT 0,
"creationDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"expirationDate" TIMESTAMP(3),
CONSTRAINT "Invite_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Invite_id_key" ON "Invite"("id");
-- AddForeignKey
ALTER TABLE "Invite" ADD CONSTRAINT "Invite_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "Community"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -1,53 +1,64 @@
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
engineType = "client"
provider = "prisma-client"
output = "../src/generated/prisma"
engineType = "client"
}
datasource db {
provider = "postgresql"
provider = "postgresql"
}
model Community {
id String @id @unique @default(uuid())
name String @unique
description String?
members User[]
Channel Channel[]
Role Role[]
id String @id @unique @default(uuid())
name String @unique
description String?
members User[]
Channel Channel[]
Role Role[]
invites Invite[]
}
model Channel {
id String @id @unique @default(uuid())
name String?
community Community? @relation(fields: [communityId], references: [id])
communityId String?
id String @id @unique @default(uuid())
name String?
community Community? @relation(fields: [communityId], references: [id])
communityId String?
}
model Role {
id String @id @unique @default(uuid())
name String?
community Community @relation(fields: [communityId], references: [id])
communityId String
id String @id @unique @default(uuid())
name String?
community Community @relation(fields: [communityId], references: [id])
communityId String
}
model User {
id String @id @unique @default(uuid())
username String @unique
email String? @unique
passwordHash String?
description String?
admin Boolean @default(false)
registerDate DateTime @default(now())
lastLogin DateTime?
Community Community? @relation(fields: [communityId], references: [id])
communityId String?
Session Session[]
id String @id @unique @default(uuid())
username String @unique
email String? @unique
passwordHash String?
description String?
admin Boolean @default(false)
registerDate DateTime @default(now())
lastLogin DateTime?
Community Community? @relation(fields: [communityId], references: [id])
communityId String?
Session Session[]
}
model Session {
id String @id @unique @default(uuid())
owner User @relation(fields: [userId], references: [id])
token String
userId String
id String @id @unique @default(uuid())
owner User @relation(fields: [userId], references: [id])
token String
userId String
}
model Invite {
id String @id @unique @default(uuid())
Community Community? @relation(fields: [communityId], references: [id])
communityId String?
totalInvites Int @default(0)
remainingInvites Int @default(0)
creationDate DateTime @default(now())
expirationDate DateTime?
}