Skip to content

Commit fd674dd

Browse files
committed
sqlc+firewalldb: add GetAction SQL query
Add a new SQL query `GetAction` to retrieve a single action by its ID. This query will be needed for the kvdb to SQL migration of actions store.
1 parent 87cf67e commit fd674dd

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

db/sqlc/actions.sql.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/queries/actions.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ UPDATE actions
1313
SET action_state = $1,
1414
error_reason = $2
1515
WHERE id = $3;
16+
17+
18+
-- name: GetAction :one
19+
SELECT *
20+
FROM actions
21+
WHERE id = $1;

firewalldb/actions_sql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type SQLActionQueries interface {
3535
SetActionState(ctx context.Context, arg sqlc.SetActionStateParams) error
3636
ListActions(ctx context.Context, arg sqlc.ListActionsParams) ([]sqlc.Action, error)
3737
CountActions(ctx context.Context, arg sqlc.ActionQueryParams) (int64, error)
38+
GetAction(ctx context.Context, id int64) (sqlc.Action, error)
3839
}
3940

4041
// sqlActionLocator helps us find an action in the SQL DB.

0 commit comments

Comments
 (0)