Delete associated machine file entries before removing main file
Added a step to delete file associations from `FilesForMachinesTable` before deleting the main file from `FilesTable`. This ensures proper cleanup of related entries in the database.
This commit is contained in:
parent
18a5999334
commit
6f0f209e00
@ -103,6 +103,13 @@ export class FilesService {
|
|||||||
}
|
}
|
||||||
if (sameFileInStorage.length === 1) {
|
if (sameFileInStorage.length === 1) {
|
||||||
//if there is one only entry then remove the file from the storage and the database.
|
//if there is one only entry then remove the file from the storage and the database.
|
||||||
|
await this.database
|
||||||
|
.use()
|
||||||
|
.delete(FilesForMachinesTable)
|
||||||
|
.where(eq(FilesForMachinesTable.fileId, fileId))
|
||||||
|
.prepare("deleteFileAssociationFromMachine")
|
||||||
|
.execute();
|
||||||
|
|
||||||
await this.database
|
await this.database
|
||||||
.use()
|
.use()
|
||||||
.delete(FilesTable)
|
.delete(FilesTable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user