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
This commit is contained in:
Sas Swart
2025-01-20 16:11:44 +00:00
parent 7f44189ed2
commit 2fca3693fc
17 changed files with 822 additions and 127 deletions

View File

@ -0,0 +1,44 @@
-- 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;