Notification UI and house invitation

This commit is contained in:
2026-02-19 19:16:26 +07:00
parent 84ed1e6c21
commit fa689ea4aa
35 changed files with 2592 additions and 112 deletions

View File

@@ -0,0 +1,54 @@
-- AlterTable
ALTER TABLE "account" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "audit" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "invitation" ALTER COLUMN "expiresAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "member" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "organization" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "session" ALTER COLUMN "expiresAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "setting" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "user" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ;
-- AlterTable
ALTER TABLE "verification" ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ;
-- CreateTable
CREATE TABLE "notification" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"title" TEXT NOT NULL,
"message" TEXT NOT NULL,
"type" TEXT NOT NULL DEFAULT 'system',
"link" TEXT,
"metadata" TEXT,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"readAt" TIMESTAMPTZ,
CONSTRAINT "notification_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "notification_userId_idx" ON "notification"("userId");
-- AddForeignKey
ALTER TABLE "notification" ADD CONSTRAINT "notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -14,11 +14,12 @@ model User {
email String
emailVerified Boolean @default(false)
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
sessions Session[]
accounts Account[]
audit Audit[]
notification Notification[]
role String?
banned Boolean? @default(false)
@@ -34,10 +35,10 @@ model User {
model Session {
id String @id @default(uuid())
expiresAt DateTime
expiresAt DateTime @db.Timestamptz
token String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
ipAddress String?
userAgent String?
userId String
@@ -65,8 +66,8 @@ model Account {
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
@@index([userId])
@@map("account")
@@ -77,8 +78,8 @@ model Verification {
identifier String
value String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
@@index([identifier])
@@map("verification")
@@ -89,7 +90,7 @@ model Organization {
name String
slug String
logo String?
createdAt DateTime
createdAt DateTime @db.Timestamptz
metadata String?
members Member[]
invitations Invitation[]
@@ -107,7 +108,7 @@ model Member {
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
role String @default("member")
createdAt DateTime
createdAt DateTime @db.Timestamptz
@@index([organizationId])
@@index([userId])
@@ -121,8 +122,8 @@ model Invitation {
email String
role String?
status String @default("pending")
expiresAt DateTime
createdAt DateTime @default(now())
expiresAt DateTime @db.Timestamptz
createdAt DateTime @default(now()) @db.Timestamptz
inviterId String
user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
@@ -138,8 +139,8 @@ model Setting {
description String
relation String @default("admin")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
@@map("setting")
}
@@ -152,9 +153,29 @@ model Audit {
recordId String
oldValue String?
newValue String?
createdAt DateTime @default(now())
createdAt DateTime @default(now()) @db.Timestamptz
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("audit")
}
model Notification {
id String @id @default(uuid())
userId String
title String
message String
type String @default("system")
link String?
metadata String?
createdAt DateTime @default(now()) @db.Timestamptz
readAt DateTime? @db.Timestamptz
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@map("notification")
}