Adding methods to delete backups on remote storage s3 and local. Some refactoring on models db and adding common.ts model with createdAt, updatedAt, and deletedAt.

This commit is contained in:
charlesgauthereau
2025-08-29 15:31:23 +02:00
parent c8da2579e8
commit 45e3b31fda
48 changed files with 310 additions and 148 deletions
+5 -4
View File
@@ -4,10 +4,11 @@ import {uploadLocalPrivate, uploadS3Private} from "@/features/upload/private/upl
import {v4 as uuidv4} from "uuid";
import {eventEmitter} from "../../../events/route";
import {db} from "@/db";
import {Backup} from "@/db/schema/06_database";
import {Backup} from "@/db/schema/07_database";
import {and, eq} from "drizzle-orm";
import * as drizzleDb from "@/db";
import {env} from "@/env.mjs";
import {withUpdatedAt} from "@/db/utils";
export async function POST(
request: Request,
@@ -135,10 +136,10 @@ export async function POST(
await db
.update(drizzleDb.schemas.backup)
.set({
.set(withUpdatedAt({
file: fileName,
status: 'success',
})
}))
.where(eq(drizzleDb.schemas.backup.id, backup.id));
eventEmitter.emit('modification', {update: true});
@@ -153,7 +154,7 @@ export async function POST(
await db
.update(drizzleDb.schemas.backup)
.set({status: 'failed'})
.set(withUpdatedAt({status: 'failed'}))
.where(eq(drizzleDb.schemas.backup.id, backup.id));
eventEmitter.emit('modification', {update: true});