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:
David Wahler
2022-07-13 15:29:34 -05:00
committed by GitHub
parent b692b7ea14
commit b5f5e909bd
12 changed files with 141 additions and 26 deletions

View File

@ -0,0 +1 @@
ALTER TABLE parameter_schemas DROP COLUMN index;

View 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;