From 0bca321219ae8cc3d34784f98bbb3fd4f6cffb8d Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Fri, 24 Sep 2021 09:11:36 +0200 Subject: [PATCH] fix: Enforce non-nullability of environment type (#950) * fix: Enforce non-nullability of environment type --- ...-add-non-null-constraint-to-environment-type.js | 14 ++++++++++++++ .../e2e/api/client/metrics.e2e.access.e2e.test.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/migrations/20210922084509-add-non-null-constraint-to-environment-type.js diff --git a/src/migrations/20210922084509-add-non-null-constraint-to-environment-type.js b/src/migrations/20210922084509-add-non-null-constraint-to-environment-type.js new file mode 100644 index 0000000000..4ea02d4486 --- /dev/null +++ b/src/migrations/20210922084509-add-non-null-constraint-to-environment-type.js @@ -0,0 +1,14 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + ` + UPDATE environments SET type = 'production' WHERE type IS null; + ALTER TABLE environments ALTER COLUMN type SET NOT NULL`, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql(`ALTER TABLE environments ALTER COLUMN type DROP NOT NULL`, cb); +}; diff --git a/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts b/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts index 347fa7b6da..d2b12b0d57 100644 --- a/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts +++ b/src/test/e2e/api/client/metrics.e2e.access.e2e.test.ts @@ -8,7 +8,7 @@ let app; let db; beforeAll(async () => { - db = await dbInit('metrics_api_client', getLogger); + db = await dbInit('metrics_api_e2e_access_client', getLogger); app = await setupAppWithAuth(db.stores); });