mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Finish migration prisma to drizzle.
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user