Update docs; Add invites to db
This commit is contained in:
parent
4f08e4d57f
commit
2fc0f9c404
4 changed files with 70 additions and 34 deletions
|
|
@ -7,10 +7,17 @@ Communication server using the Nexlink protocol
|
||||||
### Install dependencies
|
### Install dependencies
|
||||||
- npm install
|
- npm install
|
||||||
|
|
||||||
### Set up and start postgres database
|
### Set up and start postgres database (docker)
|
||||||
- docker compose pull
|
- docker compose pull
|
||||||
- docker compose up
|
- 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
|
### Create database migrations
|
||||||
- npx prisma migrate dev
|
- npx prisma migrate dev
|
||||||
|
|
||||||
|
|
|
||||||
1
env
1
env
|
|
@ -1 +1,2 @@
|
||||||
DATABASE_URL="postgresql://tetheruser:password@localhost:5432/tetherdb"
|
DATABASE_URL="postgresql://tetheruser:password@localhost:5432/tetherdb"
|
||||||
|
JWT_SECRET=""
|
||||||
|
|
|
||||||
17
prisma/migrations/20251224120739_invites/migration.sql
Normal file
17
prisma/migrations/20251224120739_invites/migration.sql
Normal 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;
|
||||||
|
|
@ -1,53 +1,64 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client"
|
provider = "prisma-client"
|
||||||
output = "../src/generated/prisma"
|
output = "../src/generated/prisma"
|
||||||
engineType = "client"
|
engineType = "client"
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
}
|
}
|
||||||
|
|
||||||
model Community {
|
model Community {
|
||||||
id String @id @unique @default(uuid())
|
id String @id @unique @default(uuid())
|
||||||
name String @unique
|
name String @unique
|
||||||
description String?
|
description String?
|
||||||
members User[]
|
members User[]
|
||||||
Channel Channel[]
|
Channel Channel[]
|
||||||
Role Role[]
|
Role Role[]
|
||||||
|
invites Invite[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Channel {
|
model Channel {
|
||||||
id String @id @unique @default(uuid())
|
id String @id @unique @default(uuid())
|
||||||
name String?
|
name String?
|
||||||
community Community? @relation(fields: [communityId], references: [id])
|
community Community? @relation(fields: [communityId], references: [id])
|
||||||
communityId String?
|
communityId String?
|
||||||
}
|
}
|
||||||
|
|
||||||
model Role {
|
model Role {
|
||||||
id String @id @unique @default(uuid())
|
id String @id @unique @default(uuid())
|
||||||
name String?
|
name String?
|
||||||
community Community @relation(fields: [communityId], references: [id])
|
community Community @relation(fields: [communityId], references: [id])
|
||||||
communityId String
|
communityId String
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @unique @default(uuid())
|
id String @id @unique @default(uuid())
|
||||||
username String @unique
|
username String @unique
|
||||||
email String? @unique
|
email String? @unique
|
||||||
passwordHash String?
|
passwordHash String?
|
||||||
description String?
|
description String?
|
||||||
admin Boolean @default(false)
|
admin Boolean @default(false)
|
||||||
registerDate DateTime @default(now())
|
registerDate DateTime @default(now())
|
||||||
lastLogin DateTime?
|
lastLogin DateTime?
|
||||||
Community Community? @relation(fields: [communityId], references: [id])
|
Community Community? @relation(fields: [communityId], references: [id])
|
||||||
communityId String?
|
communityId String?
|
||||||
Session Session[]
|
Session Session[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Session {
|
model Session {
|
||||||
id String @id @unique @default(uuid())
|
id String @id @unique @default(uuid())
|
||||||
owner User @relation(fields: [userId], references: [id])
|
owner User @relation(fields: [userId], references: [id])
|
||||||
token String
|
token String
|
||||||
userId 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?
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue