Files
coder/coderd/database/queries/presets.sql
Sas Swart 2fca3693fc adds support for workspace presets to the coderd database. Support in the API and web frontend will be added in subsequent pull requests. This is the smallest meaningful contribution that I could get passing tests for.
* Add workspace preset tables to the database in a migration
* Add queries to manipulate workspace presets to the database
* Generate db related code for the newly added queries
* Implement new methods to satisfy the Querier interface in dbauthz, dbmem, dbmock and querymetrics
* Implement the required tests for dbauthz
* Update the audit table to track changes to the new column in workspace builds
2025-02-05 14:03:37 +00:00

45 lines
1.1 KiB
SQL

-- name: InsertPreset :one
INSERT INTO
template_version_presets (template_version_id, name, created_at, updated_at)
VALUES
(@template_version_id, @name, @created_at, @updated_at) RETURNING *;
-- InsertPresetParameter :one
INSERT INTO
template_version_preset_parameters (template_version_preset_id, name, value)
VALUES
(@template_version_preset_id, @name, @value) RETURNING *;
-- name: GetPresetsByTemplateVersionID :many
SELECT
id,
name,
created_at,
updated_at
FROM
template_version_presets
WHERE
template_version_id = @template_version_id;
-- name: GetPresetByWorkspaceBuildID :one
SELECT
template_version_presets.id,
template_version_presets.name,
template_version_presets.created_at,
template_version_presets.updated_at
FROM
workspace_builds
LEFT JOIN template_version_presets ON workspace_builds.template_version_preset_id = template_version_presets.id
WHERE
workspace_builds.id = @workspace_build_id;
-- name: GetPresetParametersByPresetID :many
SELECT
id,
name,
value
FROM
template_version_preset_parameters
WHERE
template_version_preset_id = @template_version_preset_id;