Rollen Freigaben Push und Beleg Upload ueberarbeiten
All checks were successful
CI / Build (push) Successful in 2m6s
CI / Deploy (push) Successful in 2m11s

This commit is contained in:
jan
2026-05-01 15:50:37 +02:00
parent f947908f0e
commit 549c8f16c6
34 changed files with 1354 additions and 172 deletions

View File

@@ -0,0 +1,21 @@
ALTER TYPE "Role" RENAME VALUE 'ADMIN' TO 'BOARD';
ALTER TYPE "Role" ADD VALUE IF NOT EXISTS 'ORGA';
CREATE TABLE "push_subscriptions" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"endpoint" TEXT NOT NULL,
"p256dh" TEXT NOT NULL,
"auth" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "push_subscriptions_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "push_subscriptions_endpoint_key" ON "push_subscriptions"("endpoint");
CREATE INDEX "push_subscriptions_user_id_idx" ON "push_subscriptions"("user_id");
ALTER TABLE "push_subscriptions"
ADD CONSTRAINT "push_subscriptions_user_id_fkey"
FOREIGN KEY ("user_id") REFERENCES "users"("id")
ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}
datasource db {
@@ -8,7 +9,8 @@ datasource db {
}
enum Role {
ADMIN
BOARD
ORGA
FINANCE
MEMBER
}
@@ -43,12 +45,27 @@ model User {
createdExpenses Expense[] @relation("ExpenseCreator")
approvals Approval[]
auditLogs AuditLog[]
pushSubscriptions PushSubscription[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("users")
}
model PushSubscription {
id String @id @default(cuid())
userId String @map("user_id")
endpoint String @unique
p256dh String
auth String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@index([userId])
@@map("push_subscriptions")
}
model AccountingPeriod {
id String @id @default(cuid())
name String @unique

View File

@@ -131,29 +131,33 @@ async function main() {
const deko = await upsertWorkingGroup("AG Deko");
const awareness = await upsertWorkingGroup("AG Awareness");
const technik = await upsertWorkingGroup("AG Technik");
const orga = await upsertWorkingGroup("AG Orga");
const finanzen = await upsertWorkingGroup("AG Finanzen");
await upsertBudget(deko.id, currentPeriod.id, "Deko Hauptbudget", 0, "#FFB94A", 0);
await upsertBudget(awareness.id, currentPeriod.id, "Awareness Hauptbudget", 800, "#68A35D", 250);
await upsertBudget(technik.id, currentPeriod.id, "Technik Infrastruktur", 1500, "#5677F6", 500);
await upsertUser({
username: "vorstand-a",
role: Role.ADMIN,
username: "vorstand",
role: Role.BOARD,
passwordHash,
approvalPermissions: [ApprovalType.CHAIR_A]
approvalPermissions: [ApprovalType.CHAIR_B]
});
await upsertUser({
username: "vorstand-b",
role: Role.ADMIN,
username: "orga",
role: Role.ORGA,
passwordHash,
approvalPermissions: [ApprovalType.CHAIR_B]
workingGroupId: orga.id,
approvalPermissions: [ApprovalType.CHAIR_A]
});
await upsertUser({
username: "finanzen",
role: Role.FINANCE,
passwordHash,
workingGroupId: finanzen.id,
approvalPermissions: [ApprovalType.FINANCE]
});
@@ -184,4 +188,4 @@ main()
console.error(error);
await prisma.$disconnect();
process.exit(1);
});
});