Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
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 multipart from "@fastify/multipart";
|
||||||
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
||||||
|
|
||||||
@@ -534,17 +534,18 @@ export default async function adminRoutes(server: FastifyInstance) {
|
|||||||
if (!tenant) return null;
|
if (!tenant) return null;
|
||||||
|
|
||||||
const filename = tenantExportFilename(tenantId, tenant);
|
const filename = tenantExportFilename(tenantId, tenant);
|
||||||
const [job] = await server.db
|
const result = await server.db.execute(sql`
|
||||||
.insert(tenantExportJobs)
|
INSERT INTO "tenant_export_jobs"
|
||||||
.values({
|
("tenant_id", "created_by", "operation", "status", "filename", "updated_at")
|
||||||
tenantId,
|
VALUES
|
||||||
createdBy: currentUserId,
|
(${tenantId}, ${currentUserId}, 'export', 'queued', ${filename}, ${new Date()})
|
||||||
operation: "export",
|
RETURNING "id", "status", "filename";
|
||||||
status: "queued",
|
`);
|
||||||
filename,
|
const [job] = result.rows as Array<{
|
||||||
updatedAt: new Date(),
|
id: string;
|
||||||
})
|
status: string;
|
||||||
.returning(tenantExportJobColumns);
|
filename: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
void startTenantExportJob(job.id, tenantId, filename);
|
void startTenantExportJob(job.id, tenantId, filename);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user