File refs in one table

Added a file service
Refactored evidence and vendor compliance associated services and resolvers
Created SQL migration scripts
Updated GraphQL schema accordingly and the UI components
Removed unused methods and resolvers for evidence service

Signed-off-by: Yannis Varni <yannis@edinomis.fr>
This commit is contained in:
Yannis Varni
2025-10-03 15:38:00 +02:00
committed by Sacha Al Himdani
parent 3822b1916c
commit ff7ba08fc1
35 changed files with 1586 additions and 1658 deletions

View File

@@ -135,3 +135,39 @@ VALUES (
_, err := conn.Exec(ctx, q, args)
return err
}
func (f File) SoftDelete(ctx context.Context, conn pg.Conn, scope Scoper) error {
q := `
UPDATE files
SET deleted_at = NOW()
WHERE %s
AND id = @file_id
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"file_id": f.ID}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}
func (f File) HardDelete(ctx context.Context, conn pg.Conn, scope Scoper) (*string, error) {
q := `
DELETE FROM files
WHERE %s
AND id = @file_id
RETURNING file_key
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"file_id": f.ID}
maps.Copy(args, scope.SQLArguments())
var vcrFileKey *string
err := conn.QueryRow(ctx, q, args).Scan(&vcrFileKey)
return vcrFileKey, err
}