Skip to content

Commit 40d3bdb

Browse files
authored
Merge pull request #1143 from ViktorT-11/2025-07-migrate-actions
[sql-52] firewalldb: add migration code for actions from kvdb to SQL
2 parents c2c63cc + ec8b57e commit 40d3bdb

File tree

9 files changed

+1983
-32
lines changed

9 files changed

+1983
-32
lines changed

accounts/store_sql.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ type SQLQueries interface {
4949
UpdateAccountBalance(ctx context.Context, arg sqlc.UpdateAccountBalanceParams) (int64, error)
5050
UpdateAccountExpiry(ctx context.Context, arg sqlc.UpdateAccountExpiryParams) (int64, error)
5151
UpdateAccountLastUpdate(ctx context.Context, arg sqlc.UpdateAccountLastUpdateParams) (int64, error)
52+
// UpdateAccountAliasForTests is a query intended only for testing
53+
// purposes, to change the account alias.
54+
UpdateAccountAliasForTests(ctx context.Context, arg sqlc.UpdateAccountAliasForTestsParams) (int64, error)
5255
UpsertAccountPayment(ctx context.Context, arg sqlc.UpsertAccountPaymentParams) error
5356
GetAccountInvoice(ctx context.Context, arg sqlc.GetAccountInvoiceParams) (sqlc.AccountInvoice, error)
5457
}

db/sqlc/accounts.sql.go

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

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: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/queries/accounts.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ RETURNING id;
2525
INSERT INTO account_invoices (account_id, hash)
2626
VALUES ($1, $2);
2727

28+
-- name: UpdateAccountAliasForTests :one
29+
-- NOTE: This query is only intended for testing purposes.
30+
UPDATE accounts
31+
SET alias = $1
32+
WHERE id = $2
33+
RETURNING id;
34+
2835
-- name: DeleteAccountPayment :exec
2936
DELETE FROM account_payments
3037
WHERE hash = $1

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)