Continue Account log

This commit is contained in:
PxlLoewe
2026-01-30 00:25:51 +01:00
parent 005509598c
commit e4aae9804b
15 changed files with 224 additions and 24 deletions

View File

@@ -0,0 +1,22 @@
model Log {
id Int @id @default(autoincrement())
type LOG_TYPE
userId String?
browser String?
deviceId String?
ip String?
field String?
oldValue String?
newValue String?
timestamp DateTime @default(now())
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map(name: "logs")
}
enum LOG_TYPE {
LOGIN
PROFILE_CHANGE
REGISTER
}

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "is_deleted" BOOLEAN NOT NULL DEFAULT false;

View File

@@ -0,0 +1,16 @@
-- CreateEnum
CREATE TYPE "LOG_TYLE" AS ENUM ('LOGIN', 'PROFILE_CHANGE');
-- CreateTable
CREATE TABLE "logs" (
"id" SERIAL NOT NULL,
"type" "LOG_TYLE" NOT NULL,
"userId" TEXT,
"ip" TEXT,
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "logs_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "logs" ADD CONSTRAINT "logs_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -0,0 +1,16 @@
/*
Warnings:
- Changed the type of `type` on the `logs` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- CreateEnum
CREATE TYPE "LOG_TYPE" AS ENUM ('LOGIN', 'PROFILE_CHANGE', 'REGISTER');
-- AlterTable
ALTER TABLE "logs" ADD COLUMN "browser" TEXT,
DROP COLUMN "type",
ADD COLUMN "type" "LOG_TYPE" NOT NULL;
-- DropEnum
DROP TYPE "LOG_TYLE";

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "logs" ADD COLUMN "deviceId" TEXT;

View File

@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "logs" ADD COLUMN "field" TEXT,
ADD COLUMN "newValue" TEXT,
ADD COLUMN "oldValue" TEXT;

View File

@@ -1,12 +1,11 @@
model AuditLog {
model Penalty {
id Int @id @default(autoincrement())
userId String
createdUserId String?
reportId Int?
// Generalized action type to cover penalties and user history events
action AuditLogAction?
reason String?
type PenaltyType
reason String
until DateTime?
suspended Boolean @default(false)
@@ -14,18 +13,14 @@ model AuditLog {
timestamp DateTime @default(now())
// relations:
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
User User @relation("User", fields: [userId], references: [id], onDelete: Cascade)
CreatedUser User? @relation("CreatedPenalties", fields: [createdUserId], references: [id])
Report Report? @relation(fields: [reportId], references: [id])
}
enum AuditLogAction {
// Penalty actions
enum PenaltyType {
KICK
TIME_BAN
PERMISSIONS_REVOCED
BAN
// User history events
USER_DELETED
USER_PROFILE_UPDATED
}

View File

@@ -10,8 +10,8 @@ model Report {
reviewerUserId String?
// relations:
Sender User? @relation("SentReports", fields: [senderUserId], references: [id])
Reported User @relation("ReceivedReports", fields: [reportedUserId], references: [id], onDelete: Cascade)
Reviewer User? @relation("ReviewedReports", fields: [reviewerUserId], references: [id])
AuditLog AuditLog[]
Sender User? @relation("SentReports", fields: [senderUserId], references: [id])
Reported User @relation("ReceivedReports", fields: [reportedUserId], references: [id], onDelete: Cascade)
Reviewer User? @relation("ReviewedReports", fields: [reviewerUserId], references: [id])
Penalties Penalty[]
}

View File

@@ -82,14 +82,13 @@ model User {
ConnectedDispatcher ConnectedDispatcher[]
ConnectedAircraft ConnectedAircraft[]
PositionLog PositionLog[]
Penaltys AuditLog[]
CreatedAuditLogEntrys AuditLog[] @relation("CreatedAuditLogEntrys")
Bookings Booking[]
auditLogs AuditLog[]
Penaltys Penalty[] @relation("User")
CreatedPenalties Penalty[] @relation("CreatedPenalties")
Logs Log[]
Bookings Booking[]
DiscordAccount DiscordAccount?
FormerDiscordAccounts FormerDiscordAccount[]
auditLogs AuditLog[]
@@map(name: "users")
}