mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
33 lines
805 B
JavaScript
33 lines
805 B
JavaScript
|
'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);
|
||
|
};
|