lightning-terminal/db/sqlc/actions.sql.go
Elle Mouton 65e4309f9c
db: add actions schemas and queries
In this commit we define the schema for the `actions` table along with
various queries we will need for interacting with the table. NOTE: we
will also add some of our own queries manually in commits to follow.
2025-05-29 07:04:40 +02:00

78 lines
1.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: actions.sql
package sqlc
import (
"context"
"database/sql"
"time"
)
const insertAction = `-- name: InsertAction :one
INSERT INTO actions (
session_id, account_id, macaroon_identifier, actor_name, feature_name, action_trigger,
intent, structured_json_data, rpc_method, rpc_params_json, created_at,
action_state, error_reason
) VALUES (
$1, $2, $3, $4, $5, $6,
$7, $8, $9, $10, $11, $12, $13
) RETURNING id
`
type InsertActionParams struct {
SessionID sql.NullInt64
AccountID sql.NullInt64
MacaroonIdentifier []byte
ActorName sql.NullString
FeatureName sql.NullString
ActionTrigger sql.NullString
Intent sql.NullString
StructuredJsonData []byte
RpcMethod string
RpcParamsJson []byte
CreatedAt time.Time
ActionState int16
ErrorReason sql.NullString
}
func (q *Queries) InsertAction(ctx context.Context, arg InsertActionParams) (int64, error) {
row := q.db.QueryRowContext(ctx, insertAction,
arg.SessionID,
arg.AccountID,
arg.MacaroonIdentifier,
arg.ActorName,
arg.FeatureName,
arg.ActionTrigger,
arg.Intent,
arg.StructuredJsonData,
arg.RpcMethod,
arg.RpcParamsJson,
arg.CreatedAt,
arg.ActionState,
arg.ErrorReason,
)
var id int64
err := row.Scan(&id)
return id, err
}
const setActionState = `-- name: SetActionState :exec
UPDATE actions
SET action_state = $1,
error_reason = $2
WHERE id = $3
`
type SetActionStateParams struct {
ActionState int16
ErrorReason sql.NullString
ID int64
}
func (q *Queries) SetActionState(ctx context.Context, arg SetActionStateParams) error {
_, err := q.db.ExecContext(ctx, setActionState, arg.ActionState, arg.ErrorReason, arg.ID)
return err
}