Skip to content

Commit bc7e7d2

Browse files
committed
stop using gen_random_uuid
1 parent c3d8a43 commit bc7e7d2

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

coderd/database/dump.sql

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/migrations/000291_workspace_parameter_presets.up.sql

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
-- TODO (sasswart): add IF NOT EXISTS and other clauses to make the migration more robust
21
CREATE TABLE template_version_presets
32
(
4-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3+
id UUID PRIMARY KEY NOT NULL,
54
template_version_id UUID NOT NULL,
65
name TEXT NOT NULL,
76
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
8-
-- TODO (sasswart): Will auditing have any relevance to presets?
97
FOREIGN KEY (template_version_id) REFERENCES template_versions (id) ON DELETE CASCADE
108
);
119

1210
CREATE TABLE template_version_preset_parameters
1311
(
14-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
12+
id UUID PRIMARY KEY NOT NULL,
1513
template_version_preset_id UUID NOT NULL,
1614
name TEXT NOT NULL,
17-
-- TODO (sasswart): would it be beneficial to allow presets to still offer a choice for values?
18-
-- This would allow an operator to avoid having to create many similar templates where only one or
19-
-- a few values are different.
2015
value TEXT NOT NULL,
2116
FOREIGN KEY (template_version_preset_id) REFERENCES template_version_presets (id) ON DELETE CASCADE
2217
);
@@ -28,9 +23,6 @@ ALTER TABLE workspace_builds
2823
ADD CONSTRAINT workspace_builds_template_version_preset_id_fkey
2924
FOREIGN KEY (template_version_preset_id)
3025
REFERENCES template_version_presets (id)
31-
-- TODO (sasswart): SET NULL might not be the best choice here. The rest of the hierarchy has ON DELETE CASCADE.
32-
-- We don't want CASCADE here, because we don't want to delete the workspace build if the preset is deleted.
33-
-- However, do we want to lose record of the preset id for a workspace build?
3426
ON DELETE SET NULL;
3527

3628
-- Recreate the view to include the new column.

coderd/database/queries.sql.go

Lines changed: 20 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/presets.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
-- name: InsertPreset :one
22
INSERT INTO
3-
template_version_presets (template_version_id, name, created_at)
3+
template_version_presets (id, template_version_id, name, created_at)
44
VALUES
5-
(@template_version_id, @name, @created_at) RETURNING *;
5+
(@id, @template_version_id, @name, @created_at) RETURNING *;
66

77
-- name: InsertPresetParameters :many
88
INSERT INTO
9-
template_version_preset_parameters (template_version_preset_id, name, value)
9+
template_version_preset_parameters (id, template_version_preset_id, name, value)
1010
SELECT
11+
@id,
1112
@template_version_preset_id,
1213
unnest(@names :: TEXT[]),
1314
unnest(@values :: TEXT[])

0 commit comments

Comments
 (0)