From 59f1c6e8e9140f4d0630956fac560b25b2684b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Fri, 29 Oct 2021 13:02:05 +0200 Subject: [PATCH] fix: add default sort order for built in envs (#1076) --- ...add-development-and-production-environments.js | 6 +++--- .../20211029094324-set-sort-order-env.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/migrations/20211029094324-set-sort-order-env.js diff --git a/src/migrations/20210928080601-add-development-and-production-environments.js b/src/migrations/20210928080601-add-development-and-production-environments.js index e7769a0dd5..b4571d1d09 100644 --- a/src/migrations/20210928080601-add-development-and-production-environments.js +++ b/src/migrations/20210928080601-add-development-and-production-environments.js @@ -3,9 +3,9 @@ exports.up = function (db, cb) { db.runSql( ` - INSERT INTO environments(name, type, enabled) - VALUES ('development', 'development', true), - ('production', 'production', true); + INSERT INTO environments(name, type, enabled, sort_order) + VALUES ('development', 'development', true, 100), + ('production', 'production', true, 200); `, cb, ); diff --git a/src/migrations/20211029094324-set-sort-order-env.js b/src/migrations/20211029094324-set-sort-order-env.js new file mode 100644 index 0000000000..c70a48372f --- /dev/null +++ b/src/migrations/20211029094324-set-sort-order-env.js @@ -0,0 +1,15 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + ` + UPDATE environments set sort_order = 100 where name = 'development' AND sort_order = 9999; + UPDATE environments set sort_order = 200 where name = 'production' AND sort_order = 9999; + `, + cb, + ); +}; + +exports.down = function (db, cb) { + cb(); +};