mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
Return template parameters in consistent order (#2975)
* return parameters from Terraform provisioner in sorted order * persist parameter indices in database and return them in correct order from API * don't re-sort parameters by name when creating templates
This commit is contained in:
@ -0,0 +1 @@
|
||||
ALTER TABLE parameter_schemas DROP COLUMN index;
|
15
coderd/database/migrations/000029_variable_order.up.sql
Normal file
15
coderd/database/migrations/000029_variable_order.up.sql
Normal file
@ -0,0 +1,15 @@
|
||||
-- temporarily create index column as nullable
|
||||
ALTER TABLE parameter_schemas ADD COLUMN index integer;
|
||||
|
||||
-- initialize ordering for existing parameters
|
||||
WITH tmp AS (
|
||||
SELECT id, row_number() OVER (PARTITION BY job_id ORDER BY name) AS index
|
||||
FROM parameter_schemas
|
||||
)
|
||||
UPDATE parameter_schemas
|
||||
SET index = tmp.index
|
||||
FROM tmp
|
||||
WHERE parameter_schemas.id = tmp.id;
|
||||
|
||||
-- all rows should now be initialized
|
||||
ALTER TABLE parameter_schemas ALTER COLUMN index SET NOT NULL;
|
Reference in New Issue
Block a user