-- name: CreateUISetting :one
INSERT INTO "uiSettings" (namespace, key, value)
VALUES ($1, $2, $3)
RETURNING *;

-- name: GetUISetting :one
SELECT * FROM "uiSettings"
WHERE id = $1 AND "isDeleted" = FALSE;

-- name: ListUISettings :many
SELECT * FROM "uiSettings"
WHERE "isDeleted" = FALSE
ORDER BY "createdAt" ASC;

-- name: ListUISettingsByNamespace :many
SELECT * FROM "uiSettings"
WHERE "isDeleted" = FALSE AND namespace = $1
ORDER BY "createdAt" ASC;

-- name: UpdateUISetting :exec
UPDATE "uiSettings"
SET value = $2, "updatedAt" = NOW()
WHERE id = $1 AND "isDeleted" = FALSE;

-- name: SoftDeleteUISetting :exec
UPDATE "uiSettings"
SET "isDeleted" = TRUE, "updatedAt" = NOW()
WHERE id = $1;
