1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: fix sort order for environments (#3992)

This commit is contained in:
Jaanus Sellin 2023-06-15 13:27:15 +03:00 committed by GitHub
parent 650f6cc857
commit 6986534ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,32 @@
'use strict';
exports.up = function (db, callback) {
db.runSql(
`
WITH sorted_environments AS (
SELECT
*,
ROW_NUMBER() OVER (
ORDER BY
sort_order,
created_at
) AS new_sort_order
FROM
environments
)
UPDATE
environments
SET
sort_order = sorted_environments.new_sort_order
FROM
sorted_environments
WHERE
environments.name = sorted_environments.name;
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(``, callback);
};