feat: org agent management (#259)

* feat: org agent management

* feat: org agent management

* fix: adding migrations for legacy and refactoring.

* fix: refactoring

* fix: delete agent

* fix: refactoring

---------

Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
This commit is contained in:
Charles GTE
2026-04-10 18:37:35 +02:00
committed by GitHub
co-authored by charles-gauthereau
parent a620d7a9f7
commit e38519aec2
57 changed files with 13273 additions and 2089 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ import {db} from "@/db";
import {and, eq} from "drizzle-orm";
import {sendNotificationsBackupRestore} from "@/features/notifications/helpers";
import {logger} from "@/lib/logger";
import {withUpdatedAt} from "@/db/utils";
const log = logger.child({module: "api/agent/restore"});
@@ -34,7 +35,7 @@ export async function POST(
}
const agent = await db.query.agent.findFirst({
where: eq(drizzleDb.schemas.agent.id, agentId)
where: and(eq(drizzleDb.schemas.agent.id, agentId), eq(drizzleDb.schemas.agent.isArchived, false)),
})
if (!agent) {
return NextResponse.json({error: "Agent not found"}, {status: 404})
@@ -62,7 +63,7 @@ export async function POST(
await db
.update(drizzleDb.schemas.restoration)
.set({status: body.status as RestorationStatus})
.set(withUpdatedAt({status: body.status as RestorationStatus}))
.where(eq(drizzleDb.schemas.restoration.id, restoration.id));
await sendNotificationsBackupRestore(database, body.status == "failed" ? "error_restore" : "success_restore");