Projektstart

This commit is contained in:
2026-01-22 16:40:19 +01:00
parent 43c83e96bb
commit 85dee61a4d
25 changed files with 533 additions and 157 deletions

View File

@@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "ExportJob" ADD COLUMN "progress" INTEGER NOT NULL DEFAULT 0;
-- AlterTable
ALTER TABLE "MailboxAccount" ADD COLUMN "oauthLastCheckedAt" TIMESTAMP(3),
ADD COLUMN "oauthLastErrorCode" TEXT;

View File

@@ -68,6 +68,7 @@ model ExportJob {
status ExportStatus @default(QUEUED)
format String
scope String
progress Int @default(0)
filePath String?
error String?
expiresAt DateTime?
@@ -109,6 +110,8 @@ model MailboxAccount {
oauthAccessToken String?
oauthExpiresAt DateTime?
providerUserId String?
oauthLastCheckedAt DateTime?
oauthLastErrorCode String?
appPassword String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

View File

@@ -4,27 +4,34 @@ import { PrismaClient, UserRole } from "@prisma/client";
const prisma = new PrismaClient();
const tenantName = process.env.SEED_TENANT ?? "Default Tenant";
const email = process.env.SEED_EMAIL ?? "admin@example.com";
const password = process.env.SEED_PASSWORD ?? "change-me-please";
const email = process.env.SEED_ADMIN_EMAIL ?? process.env.SEED_EMAIL ?? "admin@example.com";
const password = process.env.SEED_ADMIN_PASSWORD ?? process.env.SEED_PASSWORD ?? "change-me-please";
const role = (process.env.SEED_ROLE as UserRole | undefined) ?? "ADMIN";
const main = async () => {
const hash = await argon2.hash(password);
const tenantId = process.env.SEED_TENANT_ID ?? "seed-tenant";
const tenant = await prisma.tenant.upsert({
where: { id: tenantId },
update: { name: tenantName },
create: { id: tenantId, name: tenantName }
});
const existing = await prisma.user.findUnique({ where: { email } });
if (existing) {
process.stdout.write("Seed user already exists.\n");
await prisma.user.update({
where: { email },
data: { password: hash, role, tenantId: tenant.id }
});
process.stdout.write("Seed admin updated.\n");
return;
}
const hash = await argon2.hash(password);
const tenant = await prisma.tenant.create({
data: { name: tenantName }
});
await prisma.user.create({
data: { tenantId: tenant.id, email, password: hash, role }
});
process.stdout.write("Seeded tenant and user.\n");
process.stdout.write("Seeded admin user.\n");
};
main()