add last action delete

This commit is contained in:
2026-07-28 22:00:00 +07:00
parent 5e3584e31a
commit 7aa8a50e30
6 changed files with 80 additions and 15 deletions
+23
View File
@@ -110,3 +110,26 @@ func (r *ApplicationsRepo) UpdateApplicationStatus(
}
return nil
}
func (r *ApplicationsRepo) DeleteApplicationByTeamIdAndName(ctx context.Context, teamId int, name string) error {
tag, err := r.pool.Exec(
ctx,
`DELETE FROM applications
WHERE id IN (
SELECT id
FROM applications
WHERE team_id = $1 and name = $2
ORDER BY created_at DESC
LIMIT 1
)`,
teamId,
name,
)
if err != nil {
return err
}
if tag.RowsAffected() == 0 {
return ErrApplicationNotFound
}
return nil
}