Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2026-08-31 21:44:33 +02:00

View File

@@ -1,5 +1,5 @@
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import { and, eq, inArray, isNull } from "drizzle-orm";
import { and, eq, inArray, isNull, sql } from "drizzle-orm";
import multipart from "@fastify/multipart";
import { GetObjectCommand } from "@aws-sdk/client-s3";
@@ -534,17 +534,18 @@ export default async function adminRoutes(server: FastifyInstance) {
if (!tenant) return null;
const filename = tenantExportFilename(tenantId, tenant);
const [job] = await server.db
.insert(tenantExportJobs)
.values({
tenantId,
createdBy: currentUserId,
operation: "export",
status: "queued",
filename,
updatedAt: new Date(),
})
.returning(tenantExportJobColumns);
const result = await server.db.execute(sql`
INSERT INTO "tenant_export_jobs"
("tenant_id", "created_by", "operation", "status", "filename", "updated_at")
VALUES
(${tenantId}, ${currentUserId}, 'export', 'queued', ${filename}, ${new Date()})
RETURNING "id", "status", "filename";
`);
const [job] = result.rows as Array<{
id: string;
status: string;
filename: string;
}>;
void startTenantExportJob(job.id, tenantId, filename);