mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
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:
31
coderd/database/dump.sql
generated
31
coderd/database/dump.sql
generated
@ -1265,6 +1265,21 @@ COMMENT ON COLUMN template_version_parameters.display_order IS 'Specifies the or
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.ephemeral IS 'The value of an ephemeral parameter will not be preserved between consecutive workspace builds.';
|
||||
|
||||
CREATE TABLE template_version_preset_parameters (
|
||||
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
template_version_preset_id uuid NOT NULL,
|
||||
name text NOT NULL,
|
||||
value text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE template_version_presets (
|
||||
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
template_version_id uuid NOT NULL,
|
||||
name text NOT NULL,
|
||||
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
updated_at timestamp with time zone
|
||||
);
|
||||
|
||||
CREATE TABLE template_version_variables (
|
||||
template_version_id uuid NOT NULL,
|
||||
name text NOT NULL,
|
||||
@ -1729,7 +1744,8 @@ CREATE TABLE workspace_builds (
|
||||
deadline timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
|
||||
reason build_reason DEFAULT 'initiator'::build_reason NOT NULL,
|
||||
daily_cost integer DEFAULT 0 NOT NULL,
|
||||
max_deadline timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL
|
||||
max_deadline timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
|
||||
template_version_preset_id uuid
|
||||
);
|
||||
|
||||
CREATE VIEW workspace_build_with_user AS
|
||||
@ -1747,6 +1763,7 @@ CREATE VIEW workspace_build_with_user AS
|
||||
workspace_builds.reason,
|
||||
workspace_builds.daily_cost,
|
||||
workspace_builds.max_deadline,
|
||||
workspace_builds.template_version_preset_id,
|
||||
COALESCE(visible_users.avatar_url, ''::text) AS initiator_by_avatar_url,
|
||||
COALESCE(visible_users.username, ''::text) AS initiator_by_username
|
||||
FROM (workspace_builds
|
||||
@ -2057,6 +2074,12 @@ ALTER TABLE ONLY template_usage_stats
|
||||
ALTER TABLE ONLY template_version_parameters
|
||||
ADD CONSTRAINT template_version_parameters_template_version_id_name_key UNIQUE (template_version_id, name);
|
||||
|
||||
ALTER TABLE ONLY template_version_preset_parameters
|
||||
ADD CONSTRAINT template_version_preset_parameters_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY template_version_presets
|
||||
ADD CONSTRAINT template_version_presets_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY template_version_variables
|
||||
ADD CONSTRAINT template_version_variables_template_version_id_name_key UNIQUE (template_version_id, name);
|
||||
|
||||
@ -2447,6 +2470,12 @@ ALTER TABLE ONLY tailnet_tunnels
|
||||
ALTER TABLE ONLY template_version_parameters
|
||||
ADD CONSTRAINT template_version_parameters_template_version_id_fkey FOREIGN KEY (template_version_id) REFERENCES template_versions(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY template_version_preset_parameters
|
||||
ADD CONSTRAINT template_version_preset_paramet_template_version_preset_id_fkey FOREIGN KEY (template_version_preset_id) REFERENCES template_version_presets(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY template_version_presets
|
||||
ADD CONSTRAINT template_version_presets_template_version_id_fkey FOREIGN KEY (template_version_id) REFERENCES template_versions(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY template_version_variables
|
||||
ADD CONSTRAINT template_version_variables_template_version_id_fkey FOREIGN KEY (template_version_id) REFERENCES template_versions(id) ON DELETE CASCADE;
|
||||
|
||||
|
Reference in New Issue
Block a user