Finish migration prisma to drizzle.

This commit is contained in:
charlesgauthereau
2025-07-16 18:15:28 +02:00
parent 385777535f
commit de9fe33194
21 changed files with 278 additions and 293 deletions
+16 -17
View File
@@ -1,14 +1,15 @@
import {prisma} from "@/prisma";
import {NextResponse} from "next/server";
import {Dbms} from "@prisma/client";
import {getFileUrlPresignedLocal} from "@/features/upload/private/upload.action";
import {handleDatabases} from "./helpers";
import {eventEmitter} from "../../../events/route";
import * as drizzleDb from "@/db";
import {db} from "@/db";
import {EDbmsSchema} from "@/db/schema/types";
import {eq} from "drizzle-orm";
export type databaseAgent = {
name: string,
dbms: Dbms,
dbms: EDbmsSchema,
generatedId: string
}
@@ -33,25 +34,23 @@ export async function POST(
const body: Body = await request.json();
const lastContact = new Date();
const agent = await prisma.agent.findFirst({
where: {
id: agentId
}
const agent = await db.query.agent.findFirst({
where: eq(drizzleDb.schemas.agent.id, agentId),
})
if (!agent) {
return NextResponse.json({error: "Agent not found"}, {status: 404})
}
const databasesResponse = await handleDatabases(body, agent, lastContact)
await prisma.agent.update({
where:{
id: agentId,
},
data:{
lastContact: lastContact,
}
})
eventEmitter.emit('modification', { update: true });
await db
.update(drizzleDb.schemas.agent)
.set({ lastContact: lastContact })
.where(eq(drizzleDb.schemas.agent.id, agentId));
eventEmitter.emit('modification', {update: true});
const response = {
agent: {