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

@ -7,10 +7,17 @@ Communication server using the Nexlink protocol
### Install dependencies
- npm install
### Set up and start postgres database
### Set up and start postgres database (docker)
- docker compose pull
- docker compose up
### Set up and start postgres database (podman)
- podman-compose pull
- podman-compose up
### Set up .env file and fill in the environment variables
- cp env .env
### Create database migrations
- npx prisma migrate dev

1
env
View file

@ -1 +1,2 @@
DATABASE_URL="postgresql://tetheruser:password@localhost:5432/tetherdb"
JWT_SECRET=""

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

@ -15,6 +15,7 @@ model Community {
members User[]
Channel Channel[]
Role Role[]
invites Invite[]
}
model Channel {
@ -51,3 +52,13 @@ model Session {
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?
}