Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat!: drop LegacyVariableName from coder parameter #8360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drop db legacy_variable_name
  • Loading branch information
mtojek committed Jul 7, 2023
commit cdd3c2f680b39f1f4980ed7202e68fbd7ee06a1c
3 changes: 0 additions & 3 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Unfortunately we can't bring back deleted values.

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';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE template_version_parameters DROP COLUMN legacy_variable_name;
Copy link
Member

@mafredri mafredri Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What could happen if legacy variables are still present when we upgrade? Should we somehow prevent this migration if any column has a non-empty value here?

I'm not sure what we should do, but perhaps something like this (granted the condition is needed).

DO $$
  BEGIN
    RAISE 'Bad things will happen!';
  END;
$$ LANGUAGE plpgsql;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy variable names are not used since 2 minor releases (v0.24.0, v0.25.0). I would assume that we can just drop the column :) Users who forgot to migrate workspaces will not benefit from the legacy_variable_name property.

2 changes: 0 additions & 2 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions coderd/database/queries/templateversionparameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ INSERT INTO
validation_error,
validation_monotonic,
required,
legacy_variable_name,
display_name,
display_order
)
Expand All @@ -36,8 +35,7 @@ VALUES
$13,
$14,
$15,
$16,
$17
$16
) RETURNING *;

-- name: GetTemplateVersionParameters :many
Expand Down