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:
parent
650f6cc857
commit
6986534ed8
32
src/migrations/20230615122909-fix-env-sort-order.js
Normal file
32
src/migrations/20230615122909-fix-env-sort-order.js
Normal 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);
|
||||
};
|
Loading…
Reference in New Issue
Block a user