-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaudit_logs.sql
33 lines (27 loc) · 1.21 KB
/
audit_logs.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- name: CreateAuditLog :exec
INSERT INTO audit_logs (correlation_id, actor, target_type, target_identifier, action, message)
VALUES (@correlation_id, @actor, @target_type, @target_identifier, @action, @message);
-- name: GetAuditLogsForTeam :many
SELECT * FROM audit_logs
WHERE target_type = 'team' AND target_identifier = @target_identifier
ORDER BY created_at DESC
LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset');
-- name: GetAuditLogsForTeamCount :one
SELECT COUNT(*) FROM audit_logs
WHERE target_type = 'team' AND target_identifier = @target_identifier;
-- name: GetAuditLogsForCorrelationID :many
SELECT * FROM audit_logs
WHERE correlation_id = @correlation_id
ORDER BY created_at DESC
LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset');
-- name: GetAuditLogsForCorrelationIDCount :one
SELECT COUNT(*) FROM audit_logs
WHERE correlation_id = @correlation_id;
-- name: GetAuditLogsForReconciler :many
SELECT * FROM audit_logs
WHERE target_type = 'reconciler' AND target_identifier = @target_identifier
ORDER BY created_at DESC
LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset');
-- name: GetAuditLogsForReconcilerCount :one
SELECT COUNT(*) FROM audit_logs
WHERE target_type = 'reconciler' AND target_identifier = @target_identifier;