-- name: ListScripts :many
SELECT * FROM script;

-- name: SaveScript :exec
REPLACE INTO script (name, data) VALUES (?, ?);

-- name: ListScriptVariables :many
SELECT * FROM script_variable;

-- name: UpdateScriptVariables :exec
REPLACE INTO script_variable (scope, name, value) VALUES (?, ?, ?);

-- name: ListScriptTriggers :many
SELECT * FROM script_trigger;

-- name: ReplaceScriptTrigger :exec
REPLACE INTO script_trigger (id, name, event, device_match, parameter, script_target, script_name, script_pre, script_post)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);

-- name: DeleteScriptTrigger :exec
DELETE FROM script_trigger WHERE id = ?;