Initial code
This commit is contained in:
parent
f4a1afe71b
commit
c6d3e066c9
21 changed files with 2446 additions and 0 deletions
11
prisma/migrations/20251223013400_init/migration.sql
Normal file
11
prisma/migrations/20251223013400_init/migration.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
89
prisma/migrations/20251223022822_base/migration.sql
Normal file
89
prisma/migrations/20251223022822_base/migration.sql
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- A unique constraint covering the columns `[id]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[name]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
|
||||
ADD COLUMN "admin" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "communityId" TEXT,
|
||||
ADD COLUMN "description" TEXT,
|
||||
ADD COLUMN "lastLogin" TIMESTAMP(3),
|
||||
ADD COLUMN "passwordHash" TEXT,
|
||||
ADD COLUMN "registerDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ALTER COLUMN "id" DROP DEFAULT,
|
||||
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
||||
ALTER COLUMN "email" DROP NOT NULL,
|
||||
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id");
|
||||
DROP SEQUENCE "User_id_seq";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Community" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Community_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Channel" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"communityId" TEXT,
|
||||
|
||||
CONSTRAINT "Channel_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Role" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"communityId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Session" (
|
||||
"id" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Community_id_key" ON "Community"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Community_name_key" ON "Community"("name");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Channel_id_key" ON "Channel"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Role_id_key" ON "Role"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Session_id_key" ON "Session"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_name_key" ON "User"("name");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Channel" ADD CONSTRAINT "Channel_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "Community"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Role" ADD CONSTRAINT "Role_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "Community"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "Community"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
17
prisma/migrations/20251223024429_username/migration.sql
Normal file
17
prisma/migrations/20251223024429_username/migration.sql
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `name` on the `User` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "User_name_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP COLUMN "name",
|
||||
ADD COLUMN "username" TEXT NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "postgresql"
|
||||
52
prisma/schema.prisma
Normal file
52
prisma/schema.prisma
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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
|
||||
members User[]
|
||||
Channel Channel[]
|
||||
Role Role[]
|
||||
}
|
||||
|
||||
model Channel {
|
||||
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
|
||||
}
|
||||
|
||||
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[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @unique @default(uuid())
|
||||
owner User @relation(fields: [userId], references: [id])
|
||||
token String
|
||||
userId String
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue