mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: import value from legacy variable to build parameter (#6556)
This commit is contained in:
@ -2826,6 +2826,7 @@ func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg data
|
||||
ValidationMax: arg.ValidationMax,
|
||||
ValidationMonotonic: arg.ValidationMonotonic,
|
||||
Required: arg.Required,
|
||||
LegacyVariableName: arg.LegacyVariableName,
|
||||
}
|
||||
q.templateVersionParameters = append(q.templateVersionParameters, param)
|
||||
return param, nil
|
||||
|
3
coderd/database/dump.sql
generated
3
coderd/database/dump.sql
generated
@ -353,6 +353,7 @@ CREATE TABLE template_version_parameters (
|
||||
validation_error text DEFAULT ''::text NOT NULL,
|
||||
validation_monotonic text DEFAULT ''::text NOT NULL,
|
||||
required boolean DEFAULT true NOT NULL,
|
||||
legacy_variable_name text DEFAULT ''::text NOT NULL,
|
||||
CONSTRAINT validation_monotonic_order CHECK ((validation_monotonic = ANY (ARRAY['increasing'::text, 'decreasing'::text, ''::text])))
|
||||
);
|
||||
|
||||
@ -382,6 +383,8 @@ COMMENT ON COLUMN template_version_parameters.validation_monotonic IS 'Validatio
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.required IS 'Is parameter required?';
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.legacy_variable_name IS 'Name of the legacy variable for migration purposes';
|
||||
|
||||
CREATE TABLE template_version_variables (
|
||||
template_version_id uuid NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
@ -0,0 +1 @@
|
||||
ALTER TABLE template_version_parameters DROP COLUMN legacy_variable_name;
|
@ -0,0 +1,3 @@
|
||||
ALTER TABLE template_version_parameters ADD COLUMN legacy_variable_name text NOT NULL DEFAULT '';
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.legacy_variable_name IS 'Name of the legacy variable for migration purposes';
|
@ -1470,6 +1470,8 @@ type TemplateVersionParameter struct {
|
||||
ValidationMonotonic string `db:"validation_monotonic" json:"validation_monotonic"`
|
||||
// Is parameter required?
|
||||
Required bool `db:"required" json:"required"`
|
||||
// Name of the legacy variable for migration purposes
|
||||
LegacyVariableName string `db:"legacy_variable_name" json:"legacy_variable_name"`
|
||||
}
|
||||
|
||||
type TemplateVersionVariable struct {
|
||||
|
@ -3610,7 +3610,7 @@ func (q *sqlQuerier) UpdateTemplateScheduleByID(ctx context.Context, arg UpdateT
|
||||
}
|
||||
|
||||
const getTemplateVersionParameters = `-- name: GetTemplateVersionParameters :many
|
||||
SELECT template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required FROM template_version_parameters WHERE template_version_id = $1
|
||||
SELECT template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name FROM template_version_parameters WHERE template_version_id = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetTemplateVersionParameters(ctx context.Context, templateVersionID uuid.UUID) ([]TemplateVersionParameter, error) {
|
||||
@ -3637,6 +3637,7 @@ func (q *sqlQuerier) GetTemplateVersionParameters(ctx context.Context, templateV
|
||||
&i.ValidationError,
|
||||
&i.ValidationMonotonic,
|
||||
&i.Required,
|
||||
&i.LegacyVariableName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -3667,7 +3668,8 @@ INSERT INTO
|
||||
validation_max,
|
||||
validation_error,
|
||||
validation_monotonic,
|
||||
required
|
||||
required,
|
||||
legacy_variable_name
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@ -3684,8 +3686,9 @@ VALUES
|
||||
$11,
|
||||
$12,
|
||||
$13,
|
||||
$14
|
||||
) RETURNING template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required
|
||||
$14,
|
||||
$15
|
||||
) RETURNING template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name
|
||||
`
|
||||
|
||||
type InsertTemplateVersionParameterParams struct {
|
||||
@ -3703,6 +3706,7 @@ type InsertTemplateVersionParameterParams struct {
|
||||
ValidationError string `db:"validation_error" json:"validation_error"`
|
||||
ValidationMonotonic string `db:"validation_monotonic" json:"validation_monotonic"`
|
||||
Required bool `db:"required" json:"required"`
|
||||
LegacyVariableName string `db:"legacy_variable_name" json:"legacy_variable_name"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg InsertTemplateVersionParameterParams) (TemplateVersionParameter, error) {
|
||||
@ -3721,6 +3725,7 @@ func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg Ins
|
||||
arg.ValidationError,
|
||||
arg.ValidationMonotonic,
|
||||
arg.Required,
|
||||
arg.LegacyVariableName,
|
||||
)
|
||||
var i TemplateVersionParameter
|
||||
err := row.Scan(
|
||||
@ -3738,6 +3743,7 @@ func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg Ins
|
||||
&i.ValidationError,
|
||||
&i.ValidationMonotonic,
|
||||
&i.Required,
|
||||
&i.LegacyVariableName,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ INSERT INTO
|
||||
validation_max,
|
||||
validation_error,
|
||||
validation_monotonic,
|
||||
required
|
||||
required,
|
||||
legacy_variable_name
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@ -31,7 +32,8 @@ VALUES
|
||||
$11,
|
||||
$12,
|
||||
$13,
|
||||
$14
|
||||
$14,
|
||||
$15
|
||||
) RETURNING *;
|
||||
|
||||
-- name: GetTemplateVersionParameters :many
|
||||
|
Reference in New Issue
Block a user